Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I need to save a cookie that will last for 3 weeks on my Shopify server to allow users to access a third party API without providing their login credentials each session load. With the Shopify express backend framework, how do I dynamically set a cookie and then retrieve it in future sessions?
A general example of what I understood to be the correct cookie setting/retrieving process for Shopify:
app.get('/setCookie', async (req, res) => {
res.cookie('test-cookie', 'test-cookie-data', {
signed: true,
httpOnly: true,
sameSite: 'strict',
maxAge: 99999999999 // placeholder
});
});
app.get('/getCookie', async (req, res) => {
console.log(req.signedCookies['test-cookie']);
});
However, whenever I try to access req.signedCookies or req.cookies, I am returned a null object, even after calling the setCookies route. What am I missing?
Thanks!
The thread is already two years old, but the question is still relevant. Did you find a solution back then?
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025