setcookie() and headers


I am using the code setcookie(“LoggedIn”,base64_encode($username)); And I kep on getting the error.

Warning: Cannot add header information - headers already sent by (output started at /drive2/fpgshttpd/h2oswimminguy500/UncleJohn/login.php:2) in /drive2/fpgshttpd/h2oswimminguy500/UncleJohn/login.php on line 14

I don’t know what the problem is, please help.


there is some HTML being output before your setcookie() is done

either turn on output_buffering in your .ini, or arrange your script so that there is no HTML output before the setcookie()