How can I make sure a session for a client on my express.js app lasts longer than a few hours? I don’t want them to log in anew every time they visit my site.
I tried to fiddle with the expires option on the express.session method, but that doesn’t seem to have any effect.
You can use
req.session.cookie.expires = aSpecificDateAndTime;orreq.session.cookie.maxAge = aNumberOfMilliseconds;. Both are equivalent, according to the docs.Forgot to mention, you can also set these options when setting the middleware (i.e.
express.session({secret: "whatever", cookie: {maxAge: 60000}});