Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: CGI::Session - expiry

by Herkum (Parson)
on Mar 14, 2010 at 16:22 UTC ( [id://828588]=note: print w/replies, xml ) Need Help??


in reply to CGI::Session - expiry

The easy way to test is to examine you stored session. Create your new session, check the expiry time in you database/file. Access your web page again and see if your expiry time has changed.

Now that you know HOW to check when you session is expired, you next need to look and see how you want your session to expire. If you are looking to check Idle time, well you need to reset the expiry value for the session EVERY time the user accesses the session

my $session = CGI::Session->load(); if ($session->is_expired) { # Do something like refresh the page } else { $session->expiry("+5m"); # Wait another 5 minutes }

There is nothing magical about how CGI::Session handles expiration. You set an initial expiration and that is it. By default, it will not reset the expiration value for you. There is no hidden value that deals with idle time.

Replies are listed 'Best First'.
Re^2: CGI::Session - expiry
by 2ants (Initiate) on Mar 16, 2010 at 18:30 UTC
    Thanks a lot, that's the statement I was looking for.

    I didn't have a problem knowing my session was expiring, but I could not find a statement anywhere saying how activity was recognised.

    I suppose I was half-expecting load() to re-set the expiry time itself, but I guess this way you have more flexibility around it.

      What are you two talking about? If you load the session before it expires, the timer does gets re-set, like I already showed.
      set exire to 3 seconds one second later CGI::Session=HASH(0xa965fc) / cf27e3ec9ff5a06a5bef449 +1e830c8b6 load one second later CGI::Session=HASH(0x97a164) / cf27e3ec9ff5a06a5bef449 +1e830c8b6 load one second later CGI::Session=HASH(0xbef68c) / cf27e3ec9ff5a06a5bef449 +1e830c8b6 load one second later CGI::Session=HASH(0xbef56c) / cf27e3ec9ff5a06a5bef449 +1e830c8b6 load two seconds later var=value two seconds later var=value two seconds later var=value two seconds later var=value three seconds later CGI::Session=HASH(0xa965ec) / cf27e3ec9ff5a06a5be +f4491e830c8b6 is_expired

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://828588]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-20 00:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found