Do session variables in php timeout?

Codeman

New member
If i have session variables to tell if a user is online but they have left the computer for X minutes, does the session timeout? If not what is a code to make them timeout if no activity(activity=going to other pages etc)?
 
No, the only time they can timeout (lets say) is if you create a timeout code. This is a quick example for you:
<?php
$timeparts = explode(" ",microtime());
$starttime = $timeparts[1].substr($timeparts[0],1);
if(!isset($_SESSION['name'])){
echo"Your session timed out. Please login again.";
exit;
}
?>
Above, the timer is set after an action, and if the timer runs out, it will display the echo.
 
Back
Top