CORRECTION: Problem with cookies
| From: | Andrew Wallace | Date: | Fri, 14 Mar 2003 02:17:24 +0000 |
| Subject: | CORRECTION: Problem with cookies | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-139649@lists.php.net to get a copy of this message | ||
Oops, messed up the cut'n'paste...
Hi all -
I am having a problem with cookies. It seems that if I set the
domain field in setcookie, nothing happens. I also tried creating
the cookie header manually, with the same results. This is what I
have:
$expireTime = time();
$expireTime += ($daysToExpire * 86400);
setcookie("Test1", "Thistest");
setcookie("Test2", "Thistest", $expireTime);
setcookie("Test3", "Thistest", $expireTime, "/");
setcookie("Test4", "Thistest", $expireTime, "/", "");
setcookie("Test5", "Thistest", $expireTime, "/", ".mydomain.com.");
$COOKIE = "Set-Cookie: $cookieName=$cookieValue";
$COOKIE .= "; expires=" .
gmdate("D, d-M-Y H:i:s", $expireTime) . " GMT ";
$COOKIE .= "; path=/";
$COOKIE .= "; domain=.mydomain.com.;
header ($COOKIE, false);
When I run this page in my browser, I get asked if I want to
allow cookies Test1 through Test4, but not Test5 and Test6 -
they just don't get written.
I have a perl script that does the same thing as the manual
version, I have matched up character-by-character the string
in $COOKIE with what is printed out by perl, but the perl works
and the php doesn't.
Any clues?
thanks,
andy