user2743766
user2743766

Reputation: 83

passport js How do I configure how long someone stays logged in?

Can't seem to find anything in the docs at http://passportjs.org/ or anywhere else on how to properly set how long a user stays logged in.

I've currently got passport-local working on my dev machine, but I have no idea what the duration of a login will be and can't find anything about changing the setting.

Is this because it's set within express or something I'm missing?

Upvotes: 2

Views: 1105

Answers (1)

user2743766
user2743766

Reputation: 83

As I thought might be the case, passport just uses express's session config:

app.use(express.session({ secret: 'topsecret', cookie: { maxAge: 3600000 } }))
// login sessions last 1 hour

The cookie lasts maxAge milliseconds. There are many ways to set the cookie length; this was just the one that seemed simplest to me.

Upvotes: 3

Related Questions