"headers already sent" - one cure
Hi again guys.
Re: Passing variables with cookies pp. 49-52
If you are using Notepad as your text editor and you save your file as 'somename.php' with UTF-8 encoding, you will always get "headers already sent". Apparently:
If you save your php script as UTF-8, HTML output will start at line 1 (script tag start) and setcookie() will fail.
If you save the page as ANSI setcookie() will work properly.
As an aside, I was able to set session.auto_start=0 in the php.ini file and the manual session_start() command worked for this page.
If anyone gets a "Headers already sent" error, check the encoding of your script page.
UTF-8 encoded scripts start output at the php tag declaration.
This was probably covered early in Ch. 1 and I just missed it, but for those of you who also missed it, here it is again!
|