ilmagodiloz Posted October 3, 2011 Share Posted October 3, 2011 The problem is simple. I create a cookie called usernameId in the page /home/admin/index.php. setcookie("usernameId", $value, $expireTime, "/"); After some time, if I check $_COOKIE in the page /home/index.php, the cookie $usernameId is gone. This happens only in Safari ~ OS X Lion. Is my code to create the cookie wrong? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/248330-cookie-expires-in-different-path-%C2%B7-safari/ Share on other sites More sharing options...
ilmagodiloz Posted October 3, 2011 Author Share Posted October 3, 2011 Should I also add the domain parameter? So something like this? setcookie("usernameId", $value, $expireTime, "/", ".mydomain.com"); I added the "." because the pages are in a subdomain. Quote Link to comment https://forums.phpfreaks.com/topic/248330-cookie-expires-in-different-path-%C2%B7-safari/#findComment-1275205 Share on other sites More sharing options...
Buddski Posted October 3, 2011 Share Posted October 3, 2011 All other browsers retain the cookie for the correct expiry time? How much time difference is there between the expiry time and when Safari says its gone? Quote Link to comment https://forums.phpfreaks.com/topic/248330-cookie-expires-in-different-path-%C2%B7-safari/#findComment-1275207 Share on other sites More sharing options...
ilmagodiloz Posted October 3, 2011 Author Share Posted October 3, 2011 All other browsers retain the cookie for the correct expiry time? How much time difference is there between the expiry time and when Safari says its gone? Since I've added the ".mydomain.com" parameter, Safari doesn't seem to forget cookies anymore. Anyway, the expiry time in Safari was not always the same. Sometimes I just restarted the browser and the cookie was gone in /home/index.php. Quote Link to comment https://forums.phpfreaks.com/topic/248330-cookie-expires-in-different-path-%C2%B7-safari/#findComment-1275293 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.