Correct me if I am wrong, or tell me if I am right.
When sending a header, you cannot send anything to the browser first. If the beginning of your document is a bunch of PHP and MySQL stuff, then that shouldn't cause a problem. Right?
ie:
<?
//connection to mysql
//define some functions
//define some $var
//send cookie
?>
<html>...
That shouldn't cause the cookie to fail, should it?