andreizanik / cookies-next

Getting, setting and removing cookies on both client and server with next.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot get cookies when request comes from external source

adrianbienias opened this issue · comments

Using cookies-next on the server side requires passing req, res.
But that leads to a situation when cookies cannot be get if a request comes from an external source.

Example scenario:

  1. User is logged in on website A (session cookie is set)
  2. There's a link to website A on website B
  3. User clicks that link and is redirected from website B to website A
  4. User sees that is not logged in anymore on website A (the request doesn't have cookies)
  5. User clicks a login button but then the website shows that the user is already logged in (a new request came from website A with cookies)

My bad. Everything works fine.
The issue was caused by setting sameSite option.