Hello all,
A friend and I are working on a website and we are having some issues with the timeout functionality. We set $_SESSION to the current time at login and then We are using the code below at the top of every page to set the session time every time a page is loaded. It works, except the 'activeTime' is not staying set to the new time when the next page is loaded. So the end effect is that the session expires 10 minutes from when they log-in rather than from the last activity. We have looked all over and can't find why this is happening. Any help would be much appreciated.
session_start();
//...
$maxNoActivity = 600; // Seconds of session duration of no activity
$difference = (time() - $_SESSION['activeTime']);
if($difference > $maxNoActivity)
{
session_destroy();
header("Location: login.php?timeout=1&page=".$_SERVER['PHP_SELF']);
}
$_SESSION['activeTime'] = time();