Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

how to set individual session maxAge in express?

how to set individual session maxAge in express?

Problem

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

Problem courtesy of: FurtiveFelon

Solution

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.

Solution courtesy of: Linus Gustav Larsson Thiel

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

how to set individual session maxAge in express?

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×