For high-security sites, setting a session timeout is neccessary. In any cirrcumstances, users should not stay logged in for prolonged periods of time...

We'll need 2 functions; 1 that sets the timeout of a current session and another 1 that verifies whether the session is still valid given the specied timeout variable set in function 1.

function check_login() {

@session_start();

$expiration_time = intval($_SESSION['session_expiration']);

//if session is still valid
if ($time() < $expiration_time) {
validate_session('600'); // -> make it valid for another 600 secs
return true;
}

else {
unset($_SESSION['session_expiration']);
return false;
}
}
function validate_session($timeout) {

@session_start();
$_SESSION['session_expiration'] = time() + $timeout;
}