How do i create a script that will log out the user after 10 minutes of inactivity.
Thanks.
How do i create a script that will log out the user after 10 minutes of inactivity.
Thanks.
For PHP, include this code in commonfile
if(isset($_SESSION['last_activetime'])){
if(time() - $_SESSION['last_activetime'] > 600) {
header("location:logout.php");
exit;
}
}
$_SESSION['last_activetime'] = time(); // when user open page time store in session
Each time the user does something, update a timestamp in a table somewhere for that user. Have a cron job on the server that looks in that table, and logs out anyone that is logged in but haven't had his timestamp updated in ten minutes.