Php Session Timeout

Creating an activity timeout using php:

 function check_session()
{
if (isset($_SESSION[‘last_active’]) && (time() – $_SESSION[‘last_active’] > 300))
{
// last request was more than 30 minates ago
/*                                    destroyPortalSession();
redirect(‘/’);
session_destroy();                        // destroy session data in storage
session_unset();                         // unset $_SESSION variable for the runtime */
header(“Location:/”);
}
$_SESSION[‘last_active’] = time();     // update last activity time stamp
}

You may also like...