Hi,
I am using PHP4 and facing an issue regarding session control.
I have a login page login.htm which after taking required details e.g username and password, submits it to submit.php which has the following lines to control a session.
//submit.php
session_start();
$uid = isset($_POST['uid']) ? $_POST['uid'] : $_SESSION['uid'];
$pwd = isset($_POST['pwd']) ? $_POST['pwd'] : $_SESSION['pwd'];
$_SESSION['lastaccess']= mktime();
After matching it with DB, it redirects to index.htm using header("Location:index.htm");
Now, Index.htm includes a php file called accesscontrol.php which has the following code :
//accesscontrol.php
session_start();
//header("Cache-control: private");
$newtime=mktime();
$tdiff = $newtime - $_SESSION['lastaccess'];
//echo $tdiff;
if ($tdiff > 900)
{
session_unset();
// Finally, destroy the session.
session_destroy();
exit;
}
else
{
$_SESSION['lastaccess']= mktime();
}
The problem is accesscontrol.php can't access $_SESSION['lastaccess'] which leads to further issues.
Please help.
Thanks in advance.
-Asmii