How do I dynamically set the session cookie's expires/maxAge in Express/Node.js? How do I dynamically set the session cookie's expires/maxAge in Express/Node.js? express express

How do I dynamically set the session cookie's expires/maxAge in Express/Node.js?


According to HTTP cookie's Expires and Max-Age directives, the cookie's expires date can be set to the epoch time (or a date earlier than now) and maxAge to 0:

req.session.cookie.expires = new Date(0);req.session.cookie.maxAge = 0;