Why can't I set a cookie?
Posted: Wed Aug 10, 2005 4:03 pm
I'm trying to set a cookie on a site I'm developing. Right now, the site is running off of localhost (IIS5) but the same behavior is exhibited when I publish to my demo server (RedHat w/ Apache).
I've tried with both FireFox and IE6. I DO NOT have cookies blocked. Just to be sure, I added localhost to the allowed-to-set-cookies list in FireFox. No change.
Here's the statement I'm using:
setcookie("skipsurvey","yes",time()+60*60*24*365,"/");
I've also tried:
setcookie("skipsurvey","yes");
setcookie("skipsurvey","yes",time()+60*60*24*365);
setcookie("skipsurvey","yes",time()+60*60*24*365,"/","localhost",0);
and $_COOKIE['skipsurvey'] = 'yes';
I can set session variables, but I want the data to stick around rather indefinitely so I think a cookie better suits my needs.
Nothing, zippo. No cookie. print_r($_COOKIE) shows it's not there, as does if(isset($_COOKIE['skipsurvey']))...
I'm sure it's a stupid error I've made, but I just don't see it.
Tim
I've tried with both FireFox and IE6. I DO NOT have cookies blocked. Just to be sure, I added localhost to the allowed-to-set-cookies list in FireFox. No change.
Here's the statement I'm using:
setcookie("skipsurvey","yes",time()+60*60*24*365,"/");
I've also tried:
setcookie("skipsurvey","yes");
setcookie("skipsurvey","yes",time()+60*60*24*365);
setcookie("skipsurvey","yes",time()+60*60*24*365,"/","localhost",0);
and $_COOKIE['skipsurvey'] = 'yes';
I can set session variables, but I want the data to stick around rather indefinitely so I think a cookie better suits my needs.
Nothing, zippo. No cookie. print_r($_COOKIE) shows it's not there, as does if(isset($_COOKIE['skipsurvey']))...
I'm sure it's a stupid error I've made, but I just don't see it.
Tim