slush-marklogic-node
slush-marklogic-node copied to clipboard
Implement maxAge for session cookie
Session cookie never gets lost, but it would be more elegant if it timed out after for example an hour, and is kept alive as long as people use the app. Should only take a few lines of code..
Suggested by someone:
if (!(req.path.indexOf('/api/user/') === 0 || req.path.indexOf('/app/') === 0)) {
//Change the session so we force a new set-cookie header response with
//the configured maxAge
req.session._dummy = Math.random();
}
and:
var idleTimeout = config.idleTimeout || 15 * 60 * 1000;
app.use(expressSession({
name: 'mydemo',
secret: '1fca4ecf-ed3b-4f1c-a644-61814347c9b1',
cookie: {
domain: environment === 'dev' ? undefined : '.demo.com',
maxAge: idleTimeout // millisec
},
saveUninitialized: true
}));
Also mentioned for debugging:
var debug = require('debug')('express-session');
debug('store is disconnected')
and then on commandline:
export DEBUG="express-session node server.js"