i was doing some tests with sessions...
$session = new CGI::Session("driver:File",$scookie,{'Directory'=>"/home/mysite/cgi-bin/sessions/"}) or die "$!";
if ($session->param('_IDLE_EXPIRY') < time + 120) {
$session->expire('+1m');
print "Content-Type: text/html\n\n";
print('Warn: you were away more then 2 minutes<br>we will take you to the main page.<META HTTP-EQUIV=REFRESH CONTENT="5;URL=/?>');
exit;
} else {
# add 2 minutes to the timer
$session->param('_IDLE_EXPIRY' => time + 120);
}
print "Content-Type: text/html\n\n";
print 'Time: '.$session->param('_IDLE_EXPIRY')."\n";
well its just not working as it should...
The "if" check if the timer is less then "now+2minutes" if it is your session goes to 1 minute expire and youre take to the main page to re-log if not your session is setup with 2+ minutes.
when i login in i am taken to the right message but if i refresh the page i am taken as expired.
i am using the follow code to generate the session:
$session->param('user',"$id");
$session->param('_IDLE_EXPIRY' => time + 120);
$session->expire('+1d');
Quote:
CGI::Session->name($scookie); $session = new CGI::Session("driver:File",$scookie,{'Directory'=>"/home/mysite/cgi-bin/sessions/"}) or die "$!";
if ($session->param('_IDLE_EXPIRY') < time + 120) {
$session->expire('+1m');
print "Content-Type: text/html\n\n";
print('Warn: you were away more then 2 minutes<br>we will take you to the main page.<META HTTP-EQUIV=REFRESH CONTENT="5;URL=/?>');
exit;
} else {
# add 2 minutes to the timer
$session->param('_IDLE_EXPIRY' => time + 120);
}
print "Content-Type: text/html\n\n";
print 'Time: '.$session->param('_IDLE_EXPIRY')."\n";
well its just not working as it should...
The "if" check if the timer is less then "now+2minutes" if it is your session goes to 1 minute expire and youre take to the main page to re-log if not your session is setup with 2+ minutes.
when i login in i am taken to the right message but if i refresh the page i am taken as expired.
i am using the follow code to generate the session:
Quote:
$session = new CGI::Session("driver:File",undef,{'Directory'=>"/home/mysite/cgi-bin/sessions/"}); $session->param('user',"$id");
$session->param('_IDLE_EXPIRY' => time + 120);
$session->expire('+1d');