I am setting cookie on signup route
but when i go to home route, then cookie disappears from browser
The cookie is only present on signup route, when i change route then it gets deleted
Any solution for this?
res.cookie('token', token, { maxAge: 3600*1000, httpOnly: true, })
2
Answers
Must specify the path for your entire site instead of signup route. Give a look into path and SameSite attributes.
It sounds like the issue might be related to the cookie’s configuration, particularly the path or domain options.
By default, a cookie is only available to the path where it’s set. To make it accessible across all routes, set the path option to ‘/’.
Ensure that the cookie’s domain is set correctly, especially if you’re working with subdomains.
This should make the cookie available on all routes of your application. If the issue persists, ensure that: