OK, I created this most simplistic script.. [snip]
I would expect the return on action=1 to report the set cookie, but instead, it has no data. If I then reload the browser, the cookie appears. How can I get the cookie to set without this reload? What am I missing?
Thanks a bunch... John Hinton
When you use setcookie(), it sets a Set-Cookie header in the response to the browser. The browser will then send the Cookie header with subsequent requests.
The server has no way of knowing about the cookie until a subsequent request, but you could either code around it or write your own setcookie wrapper, something like:
function setcookie2($name, $value="", $expire="", $path="", $domain="", $secure=false) {
$_COOKIES[$name] = $value;
return setcookie($name, $value, $expire, $path, $domain, $secure);
}
It's probably better just to think up an alternative way to do it though.
Best regards
-- Jasper Bryant-Greene Cabbage Promotions www: www.cabbage.co.nz email: jasper@xxxxxxxxxxxxx phone: 021 232 3303
public key: Jasper Bryant-Greene <jasper@xxxxxxxxxxxxx> keyID 0E6CDFC5 fingerprint: 2313 5641 F8F6 5606 8844 49C0 1D6B 2924 0E6C DFC5
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php