toledorodney icon

Session timeout for inactivity

toledorodney | PRO | 03/27/15 02:28:12 AM UTC | 0 ⭐ | 369 👁️ | Never ⏰ | []
PHP |

340 B

|

None

|

0 👍

/

0 👎

if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1800)) {
    // last request was more than 30 minutes ago
    session_unset();     // unset $_SESSION variable for the run-time 
    session_destroy();   // destroy session data in storage
}
$_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp

Comments