[Catalyst] Session expiry per user
    Jonathan Rockway 
    jon at jrock.us
       
    Fri Mar 14 13:40:31 GMT 2008
    
    
  
* On Fri, Mar 14 2008, Alexandre Jousset wrote:
> To set the longer expiry time, I try:
>
> $c->config->{session}{expires} = 31536000 if $c->req->param('remember_me');
You can't write to $c->config after setup runs.  It just doesn't make
sense.
Anyway, config->{session}{expires} is only consulted at session creation
time.  If you need to change the expiration later, you need to do
something else.
This might work:
  sub MyApp::calculate_extended_session_expires {
      my ($c, $prev) = @_;
      if($c->session->{remember_me}){
          return time + 31536000;
      }
      else {
          return $c->NEXT::calculate_extended_session_expires($prev);
      }
   }
And then
   $c->session->{remember_me} = 1;
   $c->calculate_extended_session_expires;
Untested.
Regards,
Jonathan Rockway
-- 
print just => another => perl => hacker => if $,=$"
    
    
More information about the Catalyst
mailing list