Sessions that timeout too early...
| From: | Steve Beilfuss | Date: | Tue, 16 Oct 2001 23:52:59 +0000 |
| Subject: | Sessions that timeout too early... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-71274@lists.php.net to get a copy of this message | ||
I am trying to make a site, that validates a login, sets up a session...but
the session will timeout after xx number of minutes.
I have attempted to use the php.ini setting for session.cookie_lifetime to
the number of seconds that the session should terminate....IF is has been
idle. What I am finding, is that the session times out whatever number of
seconds the session.cookie_lifetime is set to..from the initial
session_start(). The timer is never re-initialized as I hop from page to
page in my site.....so no matter if I'm active or not, xx seconds from
login, this session is no longer valid.
Here's the code I am using.
Page 1 - Login Authentication and initial session setup.
<?php
session_start();
.....(validate against db, etc)....
session_register("loginid");
session_register("loginname");
session_register("loginemail");
session_register("loginregion");
session_register("loginusrtype");
$loginid = $rowdata[usrID];
$loginname = $rowdata[usrName];
$loginemail = $rowdata[usrEmail];
$loginregion = $rowdata[usrRegion];
$loginusrtype = $rowdata[usrType];
?>
Page 2 - Included in every page throughout the site...as it is required
that a valid authenticated session is setup to get to any of the pages.
<?php
session_start();
if ( ! session_is_registered( "loginid")) ## Checks if valid id is set..
{
header("Location: login.php?reset=1");
exit;
}
include ("db.php");
?>