session_expires doesn't work when set in controller

1 view
Skip to first unread message

Dan

unread,
Nov 10, 2009, 5:36:53 AM11/10/09
to pylons-discuss
Hi, I'm having trouble setting session_expires in the login
controller, via a "remember me" option in the login form.

I first tried this:

if remember_me:
session.cookie_expires = timedelta(days=90)
else:
session.cookie_expires = True
session.save()

However, when testing by logging in and then closing the browser, the
session expired, so the above code didn't work.

I then tried:

if remember_me:
session['cookie_expires'] = timedelta(days=90)
else:
session['cookie_expires'] = True
session.save()

then, in my _before__ method in my base controller:

session.cookie_expires = session.get('cookie_expires', True)

Unfortunately this didn't work either. Has anyone else tried to
implement this ?

Jonathan Vanasco

unread,
Nov 10, 2009, 11:05:37 AM11/10/09
to pylons-discuss
FWIW, i don't use the beaker session to handle auto-login stuff.

My apps have 3 cookies:

beaker session
session[] data

user_id
this way other apps on the server can access login state

user_autologin_string
browser-based autologin, which can then refresh session

Dan

unread,
Nov 10, 2009, 12:07:36 PM11/10/09
to pylons-discuss
So you use response.set_cookie("foo", expires=some_date) ?

Jonathan Vanasco

unread,
Nov 10, 2009, 2:39:35 PM11/10/09
to pylons-discuss

Dan

unread,
Nov 11, 2009, 1:27:37 PM11/11/09
to pylons-discuss
I just set the cookie in response.set_cookie, that worked fine
thanks.

Just wondering why setting expiry on beaker sessions doesn't work.

alex_zh

unread,
Nov 12, 2009, 1:02:48 AM11/12/09
to pylons-discuss
Try to update Beaker
Reply all
Reply to author
Forward
0 new messages