jaymc Posted September 9, 2007 Share Posted September 9, 2007 my php.ini file specifies that a session cookie dies when the browser is closed, therefor is set to 0 Im using ini_set to manipulate this setting however cant seem to get it working I've written some test code but the session cookie is dying when the window is closed. here is the code if ($_GET[a] == "start") { ini_set('session.gc_maxlifetime', time() + 30); ini_set('session.cookie_lifetime', time() + 30); session_start(); $_SESSION['beans'] = "elolad"; echo "Loaded Session"; } else if ($_GET[a] == "now") { ini_set('session.gc_maxlifetime', time() + 30); ini_set('session.cookie_lifetime', time() + 30); session_start(); echo "session = ".$_SESSION['beans']; } Strangely, if i set the value to this ini_set('session.cookie_lifetime', 30); The session cookie does not die when I close the browser window, however, it does not die after 30 seconds either Am I doing something wrong? I dont want to alter anything in myphp.ini file, I want to make this bespoke to a website therefor want to use ini_set Cheers Quote Link to comment https://forums.phpfreaks.com/topic/68602-solved-sessioncookie_lifetime/ Share on other sites More sharing options...
jaymc Posted September 9, 2007 Author Share Posted September 9, 2007 My mistake, I forgot that everytime the page is viewed if the cookie is still valid it starts the counter again at 30 resolved Quote Link to comment https://forums.phpfreaks.com/topic/68602-solved-sessioncookie_lifetime/#findComment-344846 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.