Maybe i did not understand right how connect-mongo works.
When i set
app.use(express.session({
secret: '1234567890QWERTY',
cookie: {maxAge: 1000 * 60},
store: new MongoStore({
db: "DB"
}),
})
This suggest that the session expire after 1 minute.
But my doubt is: if the user refresh the page and on Mongo the session is refreshes too, why after 1 minute the mongo remove the entry?
I want expire the session after 1 minute, but only when user exit or stop interact with browser.
What is the better form to use session how i need?
Thanks.
add:
Oficial Doc
Note: By connect/express's default, session cookies are set to expire when the user closes their browser (maxAge: null). In accordance with standard industry practices, connect-mongo will set these sessions to expire two weeks from their last 'set'. You can override this behavior by manually setting the maxAge for your cookies -- just keep in mind that any value less than 60 seconds is pointless, as mongod will only delete expired documents in a TTL collection every minute.