verdrm Posted October 14, 2007 Share Posted October 14, 2007 Does anyone know how to set the PHP session timeout directly on a PHP page? I thought I saw something like this on the Beta test board but I can't find the page. Quote Link to comment https://forums.phpfreaks.com/topic/73157-session-timeout/ Share on other sites More sharing options...
kratsg Posted October 14, 2007 Share Posted October 14, 2007 ini_set('session.gc_maxlifetime',"300");//in seconds, maximum session lifetime ini_set('session.gc_probability',1);//leave this alone, it means that the '1' divided by the divisor gives the percentage of removing sessions, in this case: 100% ini_set('session.gc_divisor',1); ini_set('session.cookie_lifetime',"300");//maximum cookie lifetime session_save_path('/home/tmp');//I saved all my sessions outside my public_html folder (it's different for diff servers) session_start(); Change the lifetime for both cookie and gc_maxlifetime and you're set (keep them the same and you'll be fine) Quote Link to comment https://forums.phpfreaks.com/topic/73157-session-timeout/#findComment-369007 Share on other sites More sharing options...
verdrm Posted October 14, 2007 Author Share Posted October 14, 2007 Do I need to save my sessions or is that an "optional" feature? How do I carry sessions between pages? Quote Link to comment https://forums.phpfreaks.com/topic/73157-session-timeout/#findComment-369008 Share on other sites More sharing options...
kratsg Posted October 14, 2007 Share Posted October 14, 2007 Sessions are there until timeout or you kill them off. Quote Link to comment https://forums.phpfreaks.com/topic/73157-session-timeout/#findComment-369010 Share on other sites More sharing options...
verdrm Posted October 14, 2007 Author Share Posted October 14, 2007 Right, but if I use that code above on one page, but sessions exist on each page, will that automatically carry over, or do I need that code on each page? Quote Link to comment https://forums.phpfreaks.com/topic/73157-session-timeout/#findComment-369011 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.