anthonynguyen Posted February 17, 2007 Share Posted February 17, 2007 Hi Guys, I am new to PHP development and had a question with using SESSIONs in PHP and how do I set the session timeout in code. I tried a few code I found on the web but they only appear to work on a Windows environment. I am trying to get this to work within an Apache Server on a Linux box. In my code I detect if a session still exist and if not, they get redirected back to the login page. I want the session to timeout after 20 mins of inactivity. Sorry if this sounds like a stupid question but I come from an ASP/ASP.NET and ColdFusion background. It is set easily in those languages. Code examples that worked on Apache Web Servers in a LINUX environment would be awesome. Thankas ahead of time for all the help. - Anthony Link to comment https://forums.phpfreaks.com/topic/38880-session-timeout-issue/ Share on other sites More sharing options...
redarrow Posted February 17, 2007 Share Posted February 17, 2007 <?php $time_out=time(); $time_out_now=time()+1 200; if ($time_out==$time_out_now){ echo "do some think"; } ?> Link to comment https://forums.phpfreaks.com/topic/38880-session-timeout-issue/#findComment-186972 Share on other sites More sharing options...
anthonynguyen Posted February 17, 2007 Author Share Posted February 17, 2007 Thanks. Sorry I wasn't clear on what I was looking for. I tried a few options to set the session timeout in code. <?php ini_set('session.gc_maxlifetime', 1200); //this didn't work in Windows or Linux ini_set('session.cookie_lifetime', 900); //this worked in Windows but not Linux session_set_cookie_params(900); //this worked in Windows but not Linux ?> I need some piece of code that will timeout the session after 20 mins. Link to comment https://forums.phpfreaks.com/topic/38880-session-timeout-issue/#findComment-187132 Share on other sites More sharing options...
postalservice14 Posted July 17, 2007 Share Posted July 17, 2007 I am wondering the same thing. Did you ever figure it out? Thanks, John Link to comment https://forums.phpfreaks.com/topic/38880-session-timeout-issue/#findComment-300728 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.