I have a bizarre issue going on with my dev server. Just a few hours ago PHP session just totally quit working. Every single file (hundreds) started showing errors like below, about session cookies not being written. I cannot figure out what the problem is, what cause this to just start happening, before everything worked and I haven’t even made any changes. Worse of all, I cannot get it working. I tried different browsers, rebooting my server, rebooting my PC even. Nothing helps, any ideas what I can do? This is really crazy
Please note I do not have any white space or anything printing to screen before calling session_start() either
Warning: session_start()
[function.session-start]: Cannot send
session cookie – headers already sent
by (output started at
C:\webserver\htdocs\friendproject2\labs\2.php:1)
in
C:\webserver\htdocs\friendproject2\labs\2.php
on line 3Warning: session_start()
[function.session-start]: Cannot send
session cache limiter – headers
already sent (output started at
C:\webserver\htdocs\friendproject2\labs\2.php:1)
in
C:\webserver\htdocs\friendproject2\labs\2.php
on line 3 test
As I mentioned, this happens on EVERY file of my site now, even simple files. The error I posted is from a file as simple as this…
<?PHP
session_start();
$_SESSION['test'] = 'test';
echo
$_SESSION['test'];
?>
Something is getting outputed in line 1 of
C:\webserver\htdocs\friendproject2\labs\2.php.Also, where did that
testcame from?Seems like the issue was the file encoding, you should always use UTF-8 no BOM as the prefered encoding for your
.phpfiles, code editors such as Intype let you easily specify this (UTF-8 Plain).You should also read The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) by Joel Spolsky.