I read on www.php.net/setcookie that cookies must be totally handled before any output is created. To create pages on my website, I use a remote header and footer file. For instance, a page might look like this:
<HTML>
<HEAD>
<TITLE>PAGE TITLE</TITLE>
<?PHP INCLUDE 'head.txt'; ?>
PAGE CONTENT
<?PHP INCLUDE 'foot.txt'; ?>
Because they all have the <HTML>, <HEAD>, and <TITLE> tags before they begin any PHP, my pages all have output before the cookie script, which I am using for saving user preferences. For me to universally implement the script without rewriting all of my pages, I would have to put the cookie script into the head of the document. I read, however, on php.net's setcookie thing that output buffering in php4 can solve this problem. Does anyone know how this might be done or where I can find an example? It is unnecessary to go to too much trouble for this, as it is not urgent.