Reputation: 3829
I want to set a session timeout after log in using passportjs. How to set the maxAge for the session using passportjs. What is the default max age for the session that passportjs provide?
Upvotes: 12
Views: 24762
Reputation: 61
Error: Most middleware (like session) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.
Got this using latest node toolchain... so this may not work anymore.
Upvotes: 0
Reputation:
That is handled via Connect's session middleware, so for example:
.use(connect.session({ secret: 'keyboard cat', cookie: { maxAge: 60000 }}))
The documentation has other useful bits that are worth reading for understanding session handling.
Upvotes: 23
Reputation: 5055
You need to set the lifetime of the session cookie for express.session like the following example:
app.use(express.session({
secret : 'your_cookie_secret',
cookie:{_expires : 60000000}, // time im ms
})
);
For testing I recommend a shorter expires time.
Upvotes: 8