Reply to Re: [PHP] header already sent problem

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на 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

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