Weblog entry #273 for simonw
Warning: Cannot send session cookie - headers already sent by
A common error when using "session_start" in PHP is the "headers already sent". As the manual says some content got emitted to the browser already.
Usually the advice is put "<?php session_start(); ?>" as the first line in your PHP file (assuming it isn't included). This usually sorts the issue, but today it didn't work as expected!
Turns out the problem was I was using the webmaster's Microsoft Windows box with Dreamweaver and had switched it to use UTF-8 as the default character encoding, which was then quietly prefixing the files with the UTF-8 Byte Order Marker <U+FEFF>. All very obvious when I ssh'ed into the Debian box and did a "cat" on the file. Apparently some versions of Dreamweaver allow you to disable the BOM placement, I had to switch the page's encoding to "Latin-1".
Grr - guess I should stick to tools I know
Comments on this Entry
It says it all:
the problem was I was using the webmaster's Microsoft Windows box with Dreamweaver
Even though friends don't let friends use FrontPage, Dreamweaver isn't actually much better. I use to call it nightmare-maker having wasted many an hour fixing the mess that it produces... Thankfully I don't have to work with Dreamweaver created pages any more!
--
"It's Not Magic, It's Work"
Adam
[ Parent | Reply to this comment ]