Sometimes , an user leave an application without clicking on logout button, or do shutting down or hibernating of its Machine, pr even close all sessions (pages) which related t
Try this:
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 600)) { session_unset(); session_destroy(); } $_SESSION['LAST_ACTIVITY'] = time();
If $_SESSION['LAST_ACTIVITY'] > 600 no activity in last 600 seconds (10minutes) then destroy session.
$_SESSION['LAST_ACTIVITY'] > 600