Gossamer Forum
Home : General : Internet Technologies :

Re: [JoFrRi] PHP: Cookies

Quote Reply
Re: [JoFrRi] PHP: Cookies In reply to
Dan's right - cookies and any other http headers need to be called before anything is output to the browser. However, if you ever find yourself in a situation where it's unavoidable that you send http headers after already having sent output, you can get around this restriction by using output buffering.

In other words, the following works without raising any errors:

Code:
ob_start();
echo 'This is some content';
setcookie(...);
ob_end_flush();

This works with PHP 4 and later.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Subject Author Views Date
Thread PHP: Cookies JoFrRi 5345 Sep 2, 2003, 11:08 PM
Post Re: [JoFrRi] PHP: Cookies
dan 5165 Sep 2, 2003, 11:17 PM
Thread Re: [JoFrRi] PHP: Cookies
hennagaijin 5135 Sep 7, 2003, 6:55 AM
Post Re: [hennagaijin] PHP: Cookies
JoFrRi 5108 Sep 8, 2003, 11:23 AM