cookies-next
cookies-next copied to clipboard
Cookies are clear automatically when close the window
Same issue here
Check your browser settings if it is clearing all the cookies when you close the window.
you have to set a max age or it will clear automatically
Having the same issue as well, despite setting both maxAge
and expires
. I wonder if that's because I am setting the cookie on the client side.
My issue resolved , after debug my whole application , I was using SSR in my application and when ever i open the page , my get_User_Details API hit without token , that why getting session expire . and clear all the cookies .
you have to check you Application why your cookies clear .
I am also facing the same problem despite setting maxAge and expires. Is setCookies deprecated?
I thought I was the only one. I have spent hours trying to fix but the issue still persists.
I'm unsure if this is the solution, but when I store the cookie name in an environment file and use it, the cookie seems to disappear after a page refresh. However, when I hardcode the name instead of loading it from the environment, the issue gets resolved for me.
Actually for me the issue was solved as I later found out that I was using a third party cookie and not a first party one.
I'm unsure if this is the solution, but when I store the cookie name in an environment file and use it, the cookie seems to disappear after a page refresh. However, when I hardcode the name instead of loading it from the environment, the issue gets resolved for me.
I guess the env is not getting loaded correctly also this was also an issue with me in the combined approach in App directory and pages directory.
I'm unsure if this is the solution, but when I store the cookie name in an environment file and use it, the cookie seems to disappear after a page refresh. However, when I hardcode the name instead of loading it from the environment, the issue gets resolved for me.
This also the fix (not sure if this is correct) for me, but I found another case if you hardcode the cookie key, let's say in a constants.ts
, and import the cookie key the expire/max-age is set to session thus clearing the cookie when the browser is closed.
I'm unsure if this is the solution, but when I store the cookie name in an environment file and use it, the cookie seems to disappear after a page refresh. However, when I hardcode the name instead of loading it from the environment, the issue gets resolved for me.
This also the fix (not sure if this is correct) for me, but I found another case if you hardcode the cookie key, let's say in a
constants.ts
, and import the cookie key the expire/max-age is set to session thus clearing the cookie when the browser is closed.
This is also happening with other cookie library, maybe it is because "use client"
when setting the cookie but still I don't find the cause