-4

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 work properly was to put this at the very top:

ob_start("ob_gzhandler");

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

2
  • locally my login work script worked fine, etc... this host gator server is really making me put this ob_start("ob_gzhandler"); wherever i use sessions and it's annoying. there's gotta be a different way. Commented Oct 10, 2011 at 9:32
  • Frankly you just omitted the interesting part of the error message: The location of the code that caused this error. Commented Oct 10, 2011 at 17:18

2 Answers 2

1

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).

Sign up to request clarification or add additional context in comments.

6 Comments

any idea about eclipse (with aptana studio integrated)
@Ryan Frank: Eclipse normally stores w/o BOM. Save the file under a second name, delete the old file, renamed the new file to the old filename.
@ RyanFrank: try exactly what @hakre said. Eclipse should store it without BOM, but sometimes you load a project that was saved by another text editor that put in the BOM.
I did, it still says: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/ryan/public_html/demo/classes/Auth.php:1) in /home/ryan/public_html/demo/classes/Auth.php on line 3.... My Auth.php file starts off with a session_start(); though
did you try opening the file with notepad++ and saving it without the BOM?
|
1

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.

1 Comment

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/ryan/public_html/demo/classes/Auth.php:1) in /home/gerbera/public_html/demo/classes/Auth.php on line 3 I'm reading Auth.php directly and running that file directly and after <?php session_start(); is the first line.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.