AdRock Posted April 6, 2010 Share Posted April 6, 2010 I have a code snippet i've had for months but never used I presume this goes at the top of every page like you would session_start() ? When the session does expire, how do i alert the user they need to log back in again? define('SESSION_TIMEOUT', 9000); //15 Mins session_start(); $idletime = time() - isset($_SESSION['time']) ? $_SESSION['time'] : 0; if($idletime > SESSION_TIMEOUT) { //Reset session session_destroy(); session_start(); } $_SESSION['time'] = time(); Link to comment https://forums.phpfreaks.com/topic/197801-making-a-session-expire-and-alert-user/ Share on other sites More sharing options...
teamatomic Posted April 6, 2010 Share Posted April 6, 2010 Right after session_destroy. remove the session_start and put in your alert with a link to the login page. better would be to create an error then redirect to the login page and display the error just as you would for missing form data. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/197801-making-a-session-expire-and-alert-user/#findComment-1038068 Share on other sites More sharing options...
AdRock Posted April 7, 2010 Author Share Posted April 7, 2010 So where the session_start can i use a variable with the message and echo it out on the page where i want to display the error? Link to comment https://forums.phpfreaks.com/topic/197801-making-a-session-expire-and-alert-user/#findComment-1038237 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.