I have the following code to expire a session after set amount of time. It is however not working properly. If I set it for example for 1 minute or even 5 minute, it expires immediately. Can you help?
// duration in minutes * seconds
$duration = (DURATION * 60);
if(isset($_SESSION['started']))
{
// show banner and hide form
echo $msg;
$showform = 0;
if((time() - $_SESSION['started'] - $duration) > 0)
{
unset($_SESSION['count']);
unset($_SESSION['offender']);
$showform = 1;
}
}
else
{
$_SESSION['started'] = time();
}