tmyonline Posted October 3, 2008 Share Posted October 3, 2008 Hi guys, I need to log out users after 15 minutes of inactivity. I have received some advice in setting several parameters in the php.ini file but it did not seem to work. Any idea on how to achieve this ? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/126920-need-to-log-users-out-after-15-minutes-of-inactivity/ Share on other sites More sharing options...
F1Fan Posted October 3, 2008 Share Posted October 3, 2008 I think you should re-post this in one of the server boards. People that watch those boards would know more about this stuff. Quote Link to comment https://forums.phpfreaks.com/topic/126920-need-to-log-users-out-after-15-minutes-of-inactivity/#findComment-656508 Share on other sites More sharing options...
budimir Posted October 3, 2008 Share Posted October 3, 2008 Use this code! It works perfectly!!!! if ($_SESSION['last_reload'] != "" && $_SESSION['last_reload'] < strtotime("-15 minutes")) { header("Location:http://localhost/erp/logoutd.php"); } else { $_SESSION['last_reload'] = time(); } Ofcourse, on logoutd.php you need to have session_destroy(); Quote Link to comment https://forums.phpfreaks.com/topic/126920-need-to-log-users-out-after-15-minutes-of-inactivity/#findComment-656513 Share on other sites More sharing options...
tmyonline Posted October 3, 2008 Author Share Posted October 3, 2008 Hi budimir, Are you sure your code will log users out after 15 minutes of "inactivity". I don't mean log users out after 15 minutes but 15 minutes of "inactivity" !!! Quote Link to comment https://forums.phpfreaks.com/topic/126920-need-to-log-users-out-after-15-minutes-of-inactivity/#findComment-656526 Share on other sites More sharing options...
ghqwerty Posted October 3, 2008 Share Posted October 3, 2008 yes i believe thats what the $_SESSION['last_reload'] != "" && $_SESSION['last_reload'] checks i think it means if the diff between last reload and now > 15 minutes it will logout Quote Link to comment https://forums.phpfreaks.com/topic/126920-need-to-log-users-out-after-15-minutes-of-inactivity/#findComment-656541 Share on other sites More sharing options...
The Little Guy Posted October 3, 2008 Share Posted October 3, 2008 Try this snippet: http://phpsnips.com/snippet.php?id=39 Quote Link to comment https://forums.phpfreaks.com/topic/126920-need-to-log-users-out-after-15-minutes-of-inactivity/#findComment-656550 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.