How can I pause a session after a particular time (such as when user is inactive for 30 minutes) without logging the user out?
More specifically, I'd want to know when the user is logged in, when the session starts, and the duration of the session. If the user is inactive for 30 minutes, the session should be paused - but not logged out - and record the amount of "break time." If the user is still inactive for one hour, the session will be terminated and log out.
Note: If the user is active after 30 minutes, the session should restart.
My code is as follows. Can you suggest a better source for me?
include('../config/connect.php');
session_cache_expire( 20 );
session_start(); // NEVER FORGET TO START THE SESSION!!!
$inactive = 3600;
if(isset($_SESSION['start']) ) {
$session_life = time() - $_SESSION['start'];
if($session_life > $inactive){
header("Location:mylogout.php");
}
}
$_SESSION['start'] = time();
if($_SESSION['LOGIN_STATUS'] != true){
header('Location:mylogin.php');
}else{