Initially, when I designed the site, I worked with sessions on only one page, where I declared session_start(); Then it took to extend this feature to the entire site. To do this, I placed session_start() in the config.php , 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 each page of 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 I overcome this error?

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

  • Files that you specify contain an error - remove session_start () from them. he was already called in the config - Vladimir Klykov
  • The fact is that they do not have session_start (). There is only one session_start () in the config, and each erroneous file swears at it, so everyone connects the config on the first line of the code. - IntegralAL
  • I already connect the config with the very first line in the files, only in some there is no error, and in others it occurs. I am confused by the selectivity of the error, with which it is connected? - IntegralAL
  • Files in which an error occurs save in UTF8 encoding without BOM, unless of course you use UTF - ReinRaus
  • The answer below is the correct answer ... - Vladimir Klykov

3 answers 3

The error indicates that the function cannot set the HTTP response headers, since there was already output to the response body.
The function header (which in turn calls session_start) can only be used until the response body is displayed.
To correct the error, place the connection config.php at the very beginning of the text file.
If this does not help or is already there, then save the file without the BOM.

  • I agree, I misread the mistake .. explain to the person about the bom, I hardly understood what you are (the characters before <? ..) if I understood correctly ... - Vladimir Klykov
  • Yeah, right. If the encoding is with BOM, then in the file: <? include ("config.php"); ?> Before <? There are two characters that PHP defines as the response body and can no longer set headers. - ReinRaus
  • My config connects first to the file header.php, which in turn stands on the first line of all files. And all the files I have without BOM. And here I do not understand BOM? - IntegralAL
  • one
    as I thought .. everything was right for you, screen 88.198.134.41/faqs.jpg I circled the error in red, correct it, more accurately delete the extra character and enjoy working scripts - Vladimir Klykov
  • one
    productdetail.php - the first connections are clearly not a config. checkout.php is the same symbol. - Vladimir Klykov

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

Thank you all for the tip :)

    Thanks to the help, Comrade ToRcH565 managed to correct this error. The fact was that I wrote <?php not from zero position.

    • my answer was incorrect) I only indicated in which symbol the error in the BOM, so accept the one that is correct)) - Vladimir Klykov
    • oh well, don't be shy)) - IntegralAL

    Protected by spirit community member 20 Jun '17 at 7:00 .

    Thank you for your interest in this issue. Since he collected a large number of low-quality and spam responses, which had to be deleted, now it’s necessary to have 10 reputation points on the site (the bonus for account association is not counted ).

    Maybe you want to answer one of the unanswered questions ?