how to set express's session timeout

3,695 views
Skip to first unread message

xiongjiabin

unread,
Oct 13, 2011, 11:34:19 PM10/13/11
to nodejs
I am writing a auth function using node.js and express, how to set the
session timeout after log in?

Here are my code.
//in log in part
if( isValidUser(user,pass)) {
req.session.valid = true;
req.session.user = user;
}


//other part that need to determine user log in or not
if(req.session.valid) {
......
}

My problem is after some seconds or some minutes, the
req.session.valid will be removed in the session object, where is the
problem?

Cheers,
Totty

tjholowaychuk

unread,
Oct 15, 2011, 1:04:39 PM10/15/11
to nodejs
you can alter it with req.session.cookie.maxAge = milliseconds or
req.session.cookie.expires = Date
Reply all
Reply to author
Forward
0 new messages