Cookies reset on same domain #77419
Replies: 1 comment
-
This behavior is most likely due to Next.js handling cookies differently than a plain React app. In a plain React app, there's no server-side logic to process cookies, so once they're set by your server, they persist until they expire or are explicitly removed. However, Next.js—especially in development mode with version 15—has built-in server-side logic that might send its own cookie headers. This can include clearing out or resetting cookies to ensure consistency between the client and the server, or to remove stale data. In other words, when your Next.js app starts up, it might be sending a Set-Cookie header (even an empty one) that overrides or clears the cookie left by the previous plain React app. This is not necessarily a bug but rather an intentional behavior to maintain a clean state, as Next.js handles things like SSR (server-side rendering) and app routing differently. If you need to preserve certain cookies or manage them explicitly, you might need to adjust your server-side cookie logic or look into Next.js's cookie management documentation for more granular control. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Hello,
I'm interested to know why and if possible how does it happen.
Do this process again, only now, on step 2, instead of running plain react app, i'm running next.js v.15 app on 127.0.0.1:3000. The next.js app opens on the same tab, only this time the cookie disappear.
I'm trying to figure out why, and if it is something caused by next.
Thanks.
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions