Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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

In reply to Re^3: CGI::Session - expiry by Anonymous Monk
in thread CGI::Session - expiry by 2ants

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found