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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|