Reply to Re: Still fighting setcookie

Your name:

Reply:


Posted by Jasper Bryant-Greene on 03/28/05 01:27

John Hinton wrote:
> 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@cabbage.co.nz
phone: 021 232 3303

public key: Jasper Bryant-Greene <jasper@cabbage.co.nz> keyID 0E6CDFC5
fingerprint: 2313 5641 F8F6 5606 8844 49C0 1D6B 2924 0E6C DFC5

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация