Add rolling option on session to reset maxAge on every response to extend session life

This commit is contained in:
Wu Cheng-Han 2016-07-05 16:06:18 +08:00
parent 3c7d39c52d
commit f7a4f8f8c2

3
app.js
View file

@ -100,9 +100,10 @@ app.use(session({
secret: config.sessionsecret, secret: config.sessionsecret,
resave: false, //don't save session if unmodified resave: false, //don't save session if unmodified
saveUninitialized: true, //always create session to ensure the origin saveUninitialized: true, //always create session to ensure the origin
rolling: true, // reset maxAge on every response
cookie: { cookie: {
maxAge: config.sessionlife, maxAge: config.sessionlife,
expires: new Date(Date.now() + config.sessionlife), expires: new Date(Date.now() + config.sessionlife)
}, },
store: sessionStore store: sessionStore
})); }));