I'm trying to write a code that will check if an user has been inactive for one hour.
If so log him or her out when page is updated.
class_user.php
var $logtime;
function setLogTime($logtime)
{
$this->logtime = $logtime;
}
function updateTime($session_user)
{
$checklogtime = $this->logtime + 1;
echo $checklogtime;
if(date('g') >= $checklogtime && $session_user)
header('Location: login.php?do=logout');
else
$this->logtime = date('g');
}
When I echo out '$checklogtime' it's value is always '1' which is not what is supposed to happen. Where I live '$this->logtime' should output '3' so '$checklogtime' should output '4'.
login.php
$mgpuser->setLogTime(date('g'));
includes.php
$mgpuser->updateTime($_SESSION['userid']);
What should be happening is when the user logs in it'll set the hour the user logged in. The 'logtime' variable will keep updating if the user is browsing the site within the one hour time frame. If the user doesn't browse the site for one hour the user will be logged out.
What's happening now is that as soon as an user logs in he or she will be immediately logged out.