Node session expired cookie

Is it possible to create a session cookie (one that is automatically deleted when the browser is closed) And also has an expiration, so that it expires after a specified time, say 15 minutes, if the user does not continue to use the site? If they use the site, I would like to reset the expiration so that it lasts another 15 minutes.

I was really lucky to create a session cookie that ends when the browser is closed OR remains as a persistent cookie but expires using the expires or maxAge arguments.

The only thing I can think of is to create a session cookie that stores the timestamp and session middleware in it, check the current time> timestamp value, and then reject the request and delete the cookie, setting it to zero. If the current time is <= timestamp, updating the timestamp to a new date, effectively increasing the session timeout.

Although my idea may work, it makes me think that there is a more formal way to accomplish what I want.

I am currently experimenting with node and expressing so that any understanding intended for this assembly will be appreciated.

+4
source share
1 answer

cookie , , cookie.

cookie, cookie cookie. cookie:

  • .
  • cookie , session=randomNumber.
  • cookie expiry=randomNumber, 15 .
  • , cookie .

, cookie . 15 , cookie . , , cookie, , cookie .

cookie, , .

, 15- , cookie 15 .

+1

Source: https://habr.com/ru/post/1542732/


All Articles