|
Posted by Chris Shiflett on 03/25/05 23:03
AndreaD wrote:
> It's not a header it is a setcookie
setcookie() is just a function that makes setting cookies a bit more
convenient. It's still setting a header called Set-Cookie. In fact, you
can manually set cookies:
header('Set-Cookie: foo=bar');
> how do I arrange the code so the cookies are set before the header is
> set?
These are essentially the same thing, so this question doesn't make sense.
> At what point in the HTML are the headers sent.
The short answer is, as soon as there is content (HTML), you can no
longer set headers.
The more accurate answer is, PHP must send all HTTP header instructions
to Apache before it sends any content. As a developer, this means that
you need to make sure to set all of your headers before you output
anything, or you need to buffer your output using something like
ob_start(), which causes PHP to not send content to Apache before the
script terminates (or you manually flush).
Hope that helps.
Chris
--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/
[Back to original message]
|