tomcat can set session expiration policy: browser closes or times out.
but after express-session sets cookie.maxAge, browser shutdown will not cause session expiration.
so how to implement this policy in node environment
tomcat can set session expiration policy: browser closes or times out.
but after express-session sets cookie.maxAge, browser shutdown will not cause session expiration.
so how to implement this policy in node environment
try to select "session cookie" (specific google), and then delete the timed-out cookie when node processes the request.
const TIMEOUT = 1000 * 60 * 30; // 30
let middleware = function (req, res) {
let now = Date.now(); //
//
let isTimeout = req.session.ts && now - req.session.ts > TIMEOUT;
if (isTimeout) {
req.session.destroy(); // session
} else {
req.session.ts = Date.now(); //
}
}
// express-session
app.use(middleware);
Previous: How does Mongodb get the current timestamp
Next: According to the value in List, it is best to use springdata mongodb to query fuzzy query mongodb,.