I am trying to use the express-session package for session management in an express-js application.
I have the following requirements:
- Cookie is destroyed client-side when browser is closed.
- Cookie is destroyed after 15 minutes idle time.
- Cookie is destroyed after 3 hours since creation (regardless of activity).
(Numbers are just examples).
I can deal with the idle time by manipulating the cookie maxAge up to a maximum. However, when I read the express-session documentation, I see:
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.
So, how do I create a "browser-session" cookie that also has a maxAge (used for idle/absolute timeout)?
I have also investigated using node-client-session package, but it does not allow for ephemeral and maxAge.