AutoLogout After 15 minutes
Xenia Sports
by Ali Khaled
HTML
Create Timestamp database in User. timestamp
Everytime user logs in, timestamp will save.
add timestamp upon login
TO repair Auto Logout due to inactivity
JavaScript
if(time() - $_SESSION['timestamp'] > 900) { //subtract new timestamp from the old one
echo"<script>alert('15 Minutes over! Save your work please as it might log out due to inactivity');</script>";
unset($_SESSION['username'], $_SESSION['password'], $_SESSION['timestamp']);
$_SESSION['logged_in'] = false;
header("Location: " . index.php); //redirect to index.php
exit;
} else {
$_SESSION['timestamp'] = time(); //set new timestamp
}