session
session copied to clipboard
Irrespective of setting cookie maxAge to more over one hour, session is expiring after one hour
I am using express-session,storing in mongoDB and using passport authentication. irrespective what maxAge is i set , session is expiring after one hour. here is the code.
app.use(require('express-session')({
key: 'session',
resave: false, //does not forces session to be saved even when unmodified
saveUninitialized: false, //doesnt forces a session that is "uninitialized"(new but unmodified) to be saved to the store
secret: 'azuresample',
store: require('mongoose-session')(mongoose),
cookie:{maxAge: (2600000000)}// 2600000000 is for 1 month
}));
app.use(passport.initialize());
app.use(passport.session());
According to the readme of the mongoose-session module, they default sessions in MongoDB to expire in 3600 (https://www.npmjs.com/package/mongoose-session#options). You'll need to get the ttl option on the store to get longer sessions.
Thanks dougwilson, i try with that