开发者

php session weird error [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

PHP session start “Cannot send session cookie and cache limiter”

So I have been developing on my localhost, and I uploaded it to my actual web server finally, and kept getting messages saying:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent

Even though session_start() was at the top, no white space, etc...

So I did some googling, and the only way to get it to wo开发者_开发问答rk properly was to put this at the very top:

ob_start("ob_gzhandler");

What does that exactly do? Is it related to my error.


Check for BOM at the start of your documents, this what probably causes the output before the session_start(); (Most text editors have a way to save your document without BOM; In Notepad++ you go to Encoding->Encode in UTF-8 without BOM).


and kept getting messages saying: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent

This is your first fault. You have just omitted the most important part of the error message, playnly saying, where the problem code is. Did you try to read it through?

and the only way to get it to work properly was to put this at the very top: ob_start("ob_gzhandler");

This is your second fault. ob_start is not the only and not the way to go.

The only proper solution is

  1. To read the error message and locate the place where output actually started.
  2. Fix your code to make it send HTTP headers before any output.
  3. Check for the possible Byte Order Mark at the beginning of your files and eliminate it.

php session weird error

This is your third fault. One cannot call "weird" an error which has been asked a zillion times already. I'd rather call it "extremely familiar and boring" one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜