changing maxAge of session cookie at runtime.

424 views
Skip to first unread message

Amit Kumar

unread,
Apr 22, 2011, 10:23:30 AM4/22/11
to expre...@googlegroups.com
By default express sets a maxAge for the session cookie.

I wish to change the maxAge after the session cookie has been set, if the user chooses to be remembered while he logs in. So right now he'll be logged out after maxAge has expired no matter what, but I need to increase maxAge to say 1 year if the user chooses remember me.

How can i do this?

vision media [ Tj Holowaychuk ]

unread,
Apr 22, 2011, 12:14:17 PM4/22/11
to expre...@googlegroups.com
at the user-level you can do req.session.cookie.expires = someDate or req.session.cookie.maxAge = ageInMilliseconds

--
You received this message because you are subscribed to the Google Groups "Express" group.
To post to this group, send email to expre...@googlegroups.com.
To unsubscribe from this group, send email to express-js+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/express-js?hl=en.



--
Tj Holowaychuk
Vision Media
President & Creative Lead

Amit Kumar

unread,
Apr 22, 2011, 12:15:42 PM4/22/11
to expre...@googlegroups.com
will that change the maxAge for the existing cookie?

vision media [ Tj Holowaychuk ]

unread,
Apr 22, 2011, 12:18:31 PM4/22/11
to expre...@googlegroups.com
yea, the .maxAge pseudo property ends up becoming an "expires" relative to Date.now()

On Fri, Apr 22, 2011 at 9:15 AM, Amit Kumar <i.strik...@gmail.com> wrote:
will that change the maxAge for the existing cookie?
--
You received this message because you are subscribed to the Google Groups "Express" group.
To post to this group, send email to expre...@googlegroups.com.
To unsubscribe from this group, send email to express-js+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/express-js?hl=en.

vision media [ Tj Holowaychuk ]

unread,
Apr 22, 2011, 12:19:00 PM4/22/11
to expre...@googlegroups.com
not an actual cookie max-age, I think IE has issues

Amit Kumar

unread,
Apr 22, 2011, 12:24:49 PM4/22/11
to expre...@googlegroups.com
so what is the best way to implement remember me with express?
Reply all
Reply to author
Forward
0 new messages