This question has already been answered:

Hello, the problem with the PHP session:

Warning: session_start (): Cannot send session cookie - headers sent by (output started by C: \ Winginx \ home \ wc.loc \ public_html \ admin \ index.php: 1) in C: \ Winginx \ home \ wc. loc \ public_html \ protect.php on line 2 Warning: session_start (): Cannot send session cache limiter - headers already sent (output started by C: \ Winginx \ home \ wc.loc \ public_html \ admin \ index.php: 1) in C: \ Winginx \ home \ wc.loc \ public_html \ protect.php on line 2 Warning: Cannot modify header information - headers already sent by (output started by C: \ Winginx \ home \ wc.loc \ public_html \ admin \ index.php: 1) in C: \ Winginx \ home \ wc.loc \ public_html \ protect.php on line 3

UTF-8 encoding without BOM costs, there is nothing before the start of the session. Here is the beginning of the index.php code itself:

<?php require_once('../protect.php'); require_once('../database.php'); $sql_connection = dbConnect(); 

The protect.php file (also UTF-8 without BOM), it has the beginning:

 session_start(); header("Content-Type: text/html; charset=utf-8"); require_once('database.php'); 

Moreover, this project was done for a long time, and then everything worked, and the hosting also worked without problems.

PHP version: 5.3.27.

Reported as a duplicate by tutankhamun , Visman , cheops , aleksandr barakin , Denis on Oct 29 '16 at 16:20 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • he says that session_start is the third line of the file, protect.php what are the 2 previous ones? - Mike
  • @Mike, the first line only <? Php and everything, further the start of the session. I attach a screenshot i.imgur.com/luPis4p.jpg - Felix
  • 2
    "Encoding UTF-8 without BOM is worth it" - check again in the hex editor. Notice the "output started at C: \ Winginx \ home \ wc.loc \ public_html \ admin \ index.php: 1" is the string <?php - probably BOM before it is tutankhamun
  • @tutankhamun, and in truth! Something the editor let you down, or I did not watch. Thank you, otherwise I haven't sinned for anything :) - Felix

1 answer 1

Perhaps there are invisible characters in your editor. Open through another editor. Or best of all, rename the current file, create a completely new file and copy the contents into it. In theory, the editor will not copy characters that does not display.