Home php Session issue: Cannot send session cache limiter - headers already sent

Session issue: Cannot send session cache limiter – headers already sent




Initially, when I was designing the site, I worked with sessions on only one page, where I declared session_start (); Then I needed to extend this function to the entire site. To do this, I placed session_start () in the config.php file, which in turn connects to each php file of the site. This is where the problems arose …

The site structure is as follows (header files):

  • config.php
  • header.php
  • left.php
  • footer.php

These files are connected to every page on the site.
And the pages are divided into categories in which there is no session error:

  • index.php
  • shopingcart.php
  • contact.php

And the files in which the error occurs:

  • faqs.php
  • productdetail.php
  • checkout.php

How can you overcome this error?

Warning: session_start () [function.session-start]: Cannot send session cache limiter – headers already sent (output started at
S: \ home \ localhost \ www \ web_shop \ faqs.php: 1) in
S: \ home \ localhost \ www \ web_shop \ config.php on line 2

Answer 1, authority 100%

The error indicates that the function cannot set the HTTP response headers, since data has already been output to the response body.
The header function (which in turn is called by session_start) can only be used before the response body is displayed.
To fix the error, place the config.php connection at the very beginning of the file text.

Answer 2, authority 22%

Thanks to the help of comrade ToRcH565 we managed to fix this error. The point was that I did not write & lt;? Php from position zero.

Answer 3, authority 22%

Maybe someone will help!
Opened the file in Notepad ++ and saved it with UTF-8 encoding without BOM.
And uploaded the file to the hosting.
After refreshing the page, the warning disappeared!

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions