[Catalyst] Session expiry per user

Matt Lawrence matt.lawrence at ymogen.net
Fri Mar 14 12:35:39 GMT 2008


Alexandre Jousset wrote:
>     Hello Matt,
>
> Matt Lawrence a écrit :
>>>     To set the longer expiry time, I try:
>>>
>>
>> I think that will make the cookie expire on the 1st January 1971. Try 
>> "+31536000".
>
>     Looking at the "sessions" table, the value is correct, with or 
> without the '+'. The problem seems to come from the line :
>
> >> $c->config->{session}{expires} = 31536000 if
> >> $c->req->param('remember_me');
>
>     that works only once. When I request another page on the site, the 
> param 'remember_me' is not set so the sessions falls back to 1 hour 
> (tha value I've put by default).
>
Ah, I missed the fact that you were accessing the cookies via a session 
plugin, I thought you were setting them directly.

Would it be horribly perverse to store the expiry interval time (or the 
remember_me bool) in the session?

$c->config->{session}{expires} = 31536000 if $c->session->{remember_me};

>> I have a feeling that an undef expiry will result in a session 
>> cookie, based on nothing more than guesswork and superstition.
Catatlyst::Plugin::Session::State::Cookie says:

       cookie_expires
           Number of seconds from now you want to elapse before cookie will
           expire.  Set to 0 to create a session cookie, ie one which 
will die
           when the user’s browser is shut down.


Matt



More information about the Catalyst mailing list