Setcookies problem....problem with headers(possibly)

If you can’t find any of the normal reason why a “headers already sent” error is happening in your code, check the file encoding. Make sure it’s not a standard UTF-8 file. PHP isn’t technically able to handle UTF-8 file encoding.

Some editors/systems, that aren’t specifically meant for PHP development, will save files in a standard UTF-8 format, which includes some meta-data (BOM) at the front of the file. It’ll be invisible in the editor and (most likely) in the browser too, but will still count as part of the HTTP body when parsed by PHP, thus closing off the headers.

Some editors will have a UTF-8 “without BOM” or “in ASCII mode”, allowing UTF-8 encoding for PHP without this downside. (Notepad++ comes to mind.)