lalnfl Posted January 19, 2011 Share Posted January 19, 2011 So I am trying to set my session length, but it doesn't seem to be working. session_set_cookie_params("84600"); session_start(); Quote Link to comment https://forums.phpfreaks.com/topic/225026-sessions/ Share on other sites More sharing options...
TOA Posted January 19, 2011 Share Posted January 19, 2011 So I'm assuming its not setting it then? Whats the issue? Before answering, session_start needs to go first, before any output or before you can define its length, thats probably your issue Quote Link to comment https://forums.phpfreaks.com/topic/225026-sessions/#findComment-1162243 Share on other sites More sharing options...
lalnfl Posted January 19, 2011 Author Share Posted January 19, 2011 Really? I will try that. Because on PHP.net they say to call the function before you call session_start. http://us2.php.net/manual/en/function.session-set-cookie-params.php Quote Link to comment https://forums.phpfreaks.com/topic/225026-sessions/#findComment-1162249 Share on other sites More sharing options...
TOA Posted January 19, 2011 Share Posted January 19, 2011 I stand corrected, although that seems counter-intuitive to me Quote Link to comment https://forums.phpfreaks.com/topic/225026-sessions/#findComment-1162250 Share on other sites More sharing options...
lalnfl Posted January 19, 2011 Author Share Posted January 19, 2011 The issue is that when I do not reload or refresh the page for more then 10 mins or so, the session ends. And then it logs me out. I want the sessions to stay there for as long as the browser is open. Quote Link to comment https://forums.phpfreaks.com/topic/225026-sessions/#findComment-1162256 Share on other sites More sharing options...
lalnfl Posted January 20, 2011 Author Share Posted January 20, 2011 Doesn't work, anyone have a solution? Quote Link to comment https://forums.phpfreaks.com/topic/225026-sessions/#findComment-1162281 Share on other sites More sharing options...
Pikachu2000 Posted January 20, 2011 Share Posted January 20, 2011 What doesn't work? Quote Link to comment https://forums.phpfreaks.com/topic/225026-sessions/#findComment-1162283 Share on other sites More sharing options...
lalnfl Posted January 20, 2011 Author Share Posted January 20, 2011 The session_set_cookie_params. When I do this: session_set_cookie_params("86400"); session_start(); The session will destroy always in 10 mins if not active even when I set the params. Quote Link to comment https://forums.phpfreaks.com/topic/225026-sessions/#findComment-1162295 Share on other sites More sharing options...
BlueSkyIS Posted January 20, 2011 Share Posted January 20, 2011 http://php.net/manual/en/function.session-set-cookie-params.php Set cookie parameters defined in the php.ini file. The effect of this function only lasts for the duration of the script. Thus, you need to call session_set_cookie_params() for every request and before session_start() is called. this sounds like an interesting way to increase session life time. have you tried altering php.ini and/or .htaccess and/or using ini_set()? http://www.google.com/search?client=safari&rls=en&q=php+session+lifetime&ie=UTF-8&oe=UTF-8 Quote Link to comment https://forums.phpfreaks.com/topic/225026-sessions/#findComment-1162349 Share on other sites More sharing options...
PFMaBiSmAd Posted January 20, 2011 Share Posted January 20, 2011 A session consists of two parts, the session id cookie from the browser and the corresponding session data file on the server. The first parameter in session_set_cookie_params() ONLY sets the session cookie lifetime, which only means that the cookie will last for that amount of time AFTER you close the browser. This has nothing to do with the problem of the session ending while the browser is still open. A zero session cookie lifetime means that the cookie is deleted when the browser is closed. Your session data files are being deleted on the server. If you do a search on the forum, using my username and the search term session.gc_maxlifetime you will find numerous discussions about making a session last longer when there is no activity from the browser. Quote Link to comment https://forums.phpfreaks.com/topic/225026-sessions/#findComment-1162355 Share on other sites More sharing options...
lalnfl Posted January 21, 2011 Author Share Posted January 21, 2011 Is there a way to get in the php.ini file and manually change the session.gc_maxlifetime? The other methods don't seem to be working. Quote Link to comment https://forums.phpfreaks.com/topic/225026-sessions/#findComment-1163198 Share on other sites More sharing options...
lalnfl Posted January 21, 2011 Author Share Posted January 21, 2011 The reason why it was not allowing me to change the value is because I am being hosted by a free server currently. Once I upgrade to a paid server I can change the session.gc_maxlifetime. Thanks for the help guys! Quote Link to comment https://forums.phpfreaks.com/topic/225026-sessions/#findComment-1163221 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.