0
votes

I am using Express4 to develop a web app(a simple twitter). I use npm package "express-session" to manage session and cookie. But I did not set cookie.maxAge. Based on the git document we have:

By default cookie.maxAge is null, meaning no "expires" parameter is set so the cookie becomes a browser-session cookie. When the user closes the browser the cookie (and session) will be removed.

but actually, when I close my chrome and start it again, I still have the same cookie generated by server in last request.

Has anyone faced same problem? Thanks for help.

1

1 Answers

0
votes

You can try:

// This user should log in again after restarting the browser
req.session.cookie.expires = false;
   Each session has a unique cookie object accompany it. This allows
    you to alter the session cookie per visitor. For example we can
    set req.session.cookie.expires to false to enable the cookie
    to remain for only the duration of the user-agent.