After my users login, I create a session variable like this:
$_SESSION['logged_in'] = true;
And all subsequent pages, at the top of the page I do something like this:
<?php
if (!$_SESSION['logged_in']) {
header("Location: http://login.php");
}
?>
I realized that if one user logs in, but then forgets to go to the logout.php page where I do session_destroy(); then another user could hijack the account.
How do I write a test where if the user has been idle for a long time, then I automatically logout?