session icon indicating copy to clipboard operation
session copied to clipboard

Irrespective of setting cookie maxAge to more over one hour, session is expiring after one hour

Open RTBathula opened this issue 11 years ago • 2 comments

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());

RTBathula avatar Oct 19 '15 18:10 RTBathula

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.

dougwilson avatar Oct 19 '15 19:10 dougwilson

Thanks dougwilson, i try with that

RTBathula avatar Oct 19 '15 19:10 RTBathula