Session headers have already been sent

I keep getting the error below. This problem does not exist on my localhost (xampp). When the files are on the server I get this problem.

Warning : session_start () [function.session-start]: cannot send session cookie - headers already sent (output started at / home / plosta / public _html / bloom / Connections / bloom.php: 1) to / home / plosta /public_html/bloom/signin.php on line 158

it happens on the server but not on localhost

# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_bloom = "localhost";
$database_bloom = "datacenter";
$username_bloom = "root";
$password_bloom = "";
$bloom = mysql_pconnect($hostname_bloom, $username_bloom, $password_bloom) or trigger_error(mysql_error(),E_USER_ERROR); 



source to share

7 replies

The error says you have session_start()

on line 158 , try adding it on top of your file.



Start a session at the top of the page.

//before that noting

// Your code here




Make sure what session_start()

should be at the top of the code. Move the form line 158 to line 1



it looks like you include some php and make sure your Connections / bloom.php: 1 line doesn't have a line gap, space, html, etc. Yes everyone said move session_start () to line: 1, but I think you should move it to the top of the whole flow line: 1 not only in signin.php



ob_start (); ob_flush ();

place <?php ob_start(); ?>

at the top of the signin.php file and <?php ob_flush();?>

at the bottom of the sigin.php file



Usually when it says "headers already sent" It means that you have already started "output buffering" means that you have already started sending text to your user.

If this is unintentional (you don't have your code header settings), check a few things, for example:

  • Line or character before "<php" of one of your files
  • An echo that you forget somewhere in your code.


you can try with the following solutions:

  • Place a line of code <?php ob_start(); ?>

    at the top of your file

  • check your signin.php file session_start()

    should be at the top of your code. Move form line 158 to line 1

  • Please check the code if you are printing any variable / array with echo or print

    , remove this

if you can paste the whole code of the file, it will be more clear for us to give you the right solution quickly.



All Articles