Subject: | Expired parameter not expiring |
I'm running into an issue with a cgiapp, so I wrote a simple test script
to simplify the issue. It seems that there's some odd behavior when it
comes to expiring parameters when load() is used. I've attached the test
script.
Going through the debugger, I have this baffling output:
CGI::Session::load(/usr/local/share/perl/5.8.8/CGI/Session.pm:761):
761: if ( ($self->{_DATA}->{_SESSION_ATIME} +
$max_exp_interval) <= time() ) {
DB<3> p $self->{_DATA}->{_SESSION_ATIME}
1279903999
DB<4> p $param
skip_prompt
DB<5> p $max_exp_interval
7200
DB<6> p 1279903999 + 7200
1279911199
DB<7> p time()
1279921271
# ... moving outside the block
DB<8> x @expired_params
empty array
The push into @expired_params isn't called, regardless of the math
seeming like it should.
What am I doing wrong?
Subject: | 02-simple_expire.t |
#!/usr/bin/perl -w
use strict;
$|++;
use CGI::Session;
use Test::More qw/ no_plan /;
use Test::MockTime qw/ :all /;
my $session = CGI::Session->new(
'driver:file',
undef,
{ Directory => '.',
UMask => 0666,
}
);
my $testname = "got session obj";
ok( $session, $testname );
my $session_id = $session->id;
$session->param( skip_prompt => 1 );
$session->expire( 'skip_prompt', '2h' );
$session->flush;
$session = undef;
# fast forward way beyond 2h (7200)
set_relative_time(17200);
$session = CGI::Session->load(
'driver:file',
$session_id,
{ Directory => '.',
UMask => 0666,
}
);
$testname = "got session obj";
ok( $session, $testname );
$testname = "skip_prompt has expired/doesn't exist";
ok( !$session->param( 'skip_prompt' ), $testname );
$testname = "skip_prompt != 1";
isnt( $session->param( 'skip_prompt'), 1, $testname );
#$session->expire( 'skip_prompt', 0 );
#$session->param( skip_prompt => 1 );
#
#$session->flush;
#
#$session = undef;
#
#$session = CGI::Session->load(
# 'driver:file',
# $session_id,
# { Directory => '.',
# UMask => 0666,
# }
#);
#
#$testname = "got session obj";
#ok( $session, $testname );
#
#$testname = "skip_prompt = 1";
#is( $session->param( 'skip_prompt' ), 1, $testname );
END {
$session->delete;
}
__END__
Running into a weird situation with a cgiapp, so I'm simplifying it to
try to narrow it down and see if the problem lies w/ CGI::Session or
elsewhere. If CGI::Session, will file bug report.