I am using node.js with the express framework. As a session store I am using MongoDB. How can I set the lifetime after which the session objects are removed from MongoDB. This is how I am doing the declaration:
app.use(express.cookieParser());
app.use(express.session({
secret: "Stays my secret",
store: new MongoStore({ db: 'myDB' })
}));
Your question is a little vague but from what i can gather you wan’t to set the expiration period for the session:
you can use
maxAgelike so:expiresvalue is required for new versions of express where asmaxAgeis for older versions, you should only needexpiresthough.