tork Posted October 26, 2013 Share Posted October 26, 2013 Here are my relevant php.ini settings: session.name = hello session.cookie_lifetime = 30 session.cookie_path = / session.cookie_domain = .name.com And my script: session_start();setcookie('hello', '', time(), '/', '.name.com'); The php.ini value works as expected with the cookie being created and then timing out after 30 seconds - confirmed in Firebug under 'Cookies'. Then I add the session_set_cookie_params statement with 75 second expiry: session_set_cookie_params(75, '/', '.name.com'); session_start();setcookie('hello', '', time(), '/', '.name.com'); When I look at the Cookies tab in Firebug, no cookie shows up. Now I reckoned that the session_set_cookie_params 75 seconds would overwrite the php.ini session.cookie_lifetime value of 30 seconds, and the setcookie create a cookie timed to expire 75 seconds later, yet they seem not to. Why is this? Quote Link to comment https://forums.phpfreaks.com/topic/283312-session_set_cookie_params-not-overwriting-phpini-parameter/ Share on other sites More sharing options...
Ch0cu3r Posted October 26, 2013 Share Posted October 26, 2013 the session.cookie_* settings only affect the PHP session cookie that is created with the session_start() function. Those settings have no effect on cookies set using setcookie() This setcookie('hello', '', time(), '/', '.name.com'); sets a cookie called hello and is immediately expired. To make it expire 75 seconds later you need to set the expire time param to time()+75 session_set_cookie_params do override the default settings defined in the php.ini. You should be able to verify this using session_get_cookie_params before and after changing the cookie params. Quote Link to comment https://forums.phpfreaks.com/topic/283312-session_set_cookie_params-not-overwriting-phpini-parameter/#findComment-1455553 Share on other sites More sharing options...
tork Posted October 26, 2013 Author Share Posted October 26, 2013 Ah! That explains it! Thanks Ch0cu3r. Quote Link to comment https://forums.phpfreaks.com/topic/283312-session_set_cookie_params-not-overwriting-phpini-parameter/#findComment-1455558 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.