Moptop650 Posted May 15, 2007 Share Posted May 15, 2007 My cookies set by php are always deleting themselves when I close the browser. (NOT a browser preferance issue, I've checked. Im using: setcookie("mc-pref", $prefs, time()+525600); And have tried: setcookie("mc-pref", $prefs, time+525600); setcookie("mc-pref", $prefs, $time+525600); What am I doing wrong? Quote Link to comment Share on other sites More sharing options...
trq Posted May 16, 2007 Share Posted May 16, 2007 What happens when you use.... setcookie("mc-pref", $prefs, time()+60*60*24*30); ? The above code should expire the cookie in 30 days. Quote Link to comment Share on other sites More sharing options...
Moptop650 Posted May 17, 2007 Author Share Posted May 17, 2007 I have it set to expire in a year already. Quote Link to comment Share on other sites More sharing options...
ryeman98 Posted May 17, 2007 Share Posted May 17, 2007 Doesn't a year seem kind of long though? I know very little about cookies and I would set mine for no more than 90 days... Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted May 17, 2007 Share Posted May 17, 2007 If the cookies are deleted when the browser is closed, and no other time, I find it very hard to believe it's anything but a setting in the browser. Perhaps, if you are on an AD domain, it's a profile setting that is clearing the cookies folder at logout. Quote Link to comment Share on other sites More sharing options...
per1os Posted May 17, 2007 Share Posted May 17, 2007 Maybe try using more of the setcookie parameters, such as domain and path??? www.php.net/setcookie <?php //bool setcookie ( string $name [, string $value [, int $expire [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]]] ) // remember add www. if your site is always referenced by www. if not than just use yourdomain.com setcookie("mc-pref", $prefs, time()+525600, '/', 'yourdomain.com'); Cookies can sometimes be very specific meaning they require a path and a domainname to work properly. Also if you are working on LOCALHOST I would highly suggest looking at this: http://www.aeonity.com/frost/php-setcookie-localhost-apache 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.