Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: CGI::Session - expiry

by Anonymous Monk
on Mar 16, 2010 at 21:50 UTC ( #829026=note: print w/ replies, xml ) Need Help??


in reply to Re^2: CGI::Session - expiry
in thread CGI::Session - expiry

What are you two talking about? If you load the session before it expires, the timer does gets re-set, like I already showed.

#!/usr/bin/perl -- use strict; use warnings; use CGI(); use CGI::Session(); my ($oneid); { my $one = CGI::Session->new or die CGI::Session->errstr; $one->expire('3s'); $one->param(qw' var value '); $oneid = $one->id; print "set exire to 3 seconds\n"; } for my $loop ( 1 .. 4 ) { sleep 1; my $bob = CGI::Session->load($oneid) or die CGI::Session->errstr; print "one second later $bob / $oneid load\n"; } for my $loop ( 1 .. 4 ) { sleep 2; my $bob = CGI::Session->load($oneid) or die CGI::Session->errstr; print "two seconds later "; if ( $bob->is_expired ) { print "$bob / $oneid is_expired\n"; } else { print "var=", $bob->param('var'), "\n"; } } ## end for my $loop ( 1 .. 4 ) { sleep 3; my $bob = CGI::Session->load($oneid) or die CGI::Session->errstr; print "three seconds later "; if ( $bob->is_expired ) { print "$bob / $oneid is_expired\n"; } else { print "var=", $bob->param('var'), "\n"; } } __END__
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


Comment on Re^3: CGI::Session - expiry
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2014-07-14 03:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (254 votes), past polls