How to set the session timeout after log in passportjs?

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.


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.