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:
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
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