Cookie issues

My response header contains a valid set cookie header but the cookie is not being saved in my browser cookie storage
3 Replies
CodyC
CodyC2mo ago
What API are you using to set the cookie? Can you verify the cookie header was received by your browser? Why do you think it's not stored by your browser? (How did you verify?) Have any code/screenshots? It's hard to debug with just the info you have provided.
Mr.Possumz
Mr.Possumz2mo ago
can you provide a screenshot of the browser's network call response headers to show us what the cookie on the response looks like and what header it's passed under?
TheOneThatPlaysTooMuch
I fixed the problem, and now the code for setting the cookie looks like this:
ctx.response.headers.append(
"set-cookie",
`session=${session.secret}; Path=/; HttpOnly; Secure; SameSite=Lax; `,
);
ctx.response.headers.append(
"set-cookie",
`session=${session.secret}; Path=/; HttpOnly; Secure; SameSite=Lax; `,
);
But I still don't understand, why does adding those attributes make it work? which one of them made it work? where can I read more about this? also why is it that the cookie always registered with Expires=session instead of the actual expiration date when I tried to add it?

Did you find this page helpful?