stockton Posted February 21, 2008 Share Posted February 21, 2008 I have written a little program which appears to work fine but..... The code looks like:- <?php session_start(); // Get the current Session Timeout Value $currentTimeoutInSecs = ini_get('session.gc_maxlifetime'); echo "\nDefault timeout = ".$currentTimeoutInSecs." seconds\n"; // Change the session timeout value to 30 minutes ini_set('session.gc_maxlifetime', 30*60); $currentTimeoutInSecs = ini_get('session.gc_maxlifetime'); echo "Altered timeout = ".$currentTimeoutInSecs." seconds\n"; ?> and this appears to work fine except that the second time I run it I would expect to see the default time altered to what I set it to rather than what it was in the 1st place. No matter how many times I run it the results are always:- Default timeout = 1440 seconds Altered timeout = 1800 seconds Please tell me why. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 21, 2008 Share Posted February 21, 2008 ini_set() statements only changed the setting for the duration of the script. From the ini_set() section of the php manual - The configuration option will keep this new value during the script's execution, and will be restored at the script's ending. You must also set any session settings before the session_start() for them to affect that session. Quote Link to comment Share on other sites More sharing options...
stockton Posted February 22, 2008 Author Share Posted February 22, 2008 Thank you. Quote Link to comment 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.