Re: header already sent problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux