36

I understand that you can set the maxAge when starting up the app as follows:

connect.session({ secret: 'keyboard cat', cookie: { maxAge: 60000 }})

However, i would like to implement something along the lines of "remember me" setting, how would i go about doing that?

Thanks a lot :)

Jason

FurtiveFelon
  • 14,714
  • 27
  • 76
  • 97

1 Answers1

61

You can set either expires or maxAge on the individual cookie belonging to the current user:

// This user should log in again after restarting the browser
req.session.cookie.expires = false;

// This user won't have to log in for a year
req.session.cookie.maxAge = 365 * 24 * 60 * 60 * 1000;

See connect session documentation.

Linus Thiel
  • 38,647
  • 9
  • 109
  • 104