Search code examples
phpjavascriptfirefoxcookiesmootools

php's "setcookie" doesn't work cross-browser?


At the moment I'm using setcookie to set my cookies, however it only works in Firefox and Safari, and cookies are not set in IE and Chrome (and maybe other browsers).

setcookie($name, $value, time()+3600 * 25);

I read in an article about setcookie and IE, that if the expiry date is in the past (or is too small), IE simply ignores it.

I know Javascript can set cookies (I'm using MooTools) but I'd prefer using php and MooTools & cookies isn't working for me.

Any help would be appreciated.


Solution

  • Check your server's clock. If it's running more than 25 hours behind, the time() + 3600 * 25 could still be in the past as far as the browser is concerned.