Add session timeout to mailwatch webpage

Questions and answers about how to do stuff
Post Reply
z3us
Posts: 8
Joined: 22 Jul 2016 17:10

Add session timeout to mailwatch webpage

Post by z3us »

Hey guys,

add following code to login.function.php to configure browser session time-out after inactivity (security feature):

Code: Select all

// extra code for session timeout - 1800 = seconds = 30 minutes
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
    header("Location: index.php");
}
$_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp
Improvements in code are always welcome!
Peace out!
Post Reply