torsuntsu Posted October 28, 2013 Share Posted October 28, 2013 Hello, i´m getting a warning: Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/sistemag/public_html/index.php:3) in /home/sistemag/public_html/core/init.php on line 1 and i can´t figure it out why. I just moved my code to another server and this warning began to apear. On the previous server i got no warnings. Can somebody help me with this one? Many thanks, TorSunTsu Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted October 28, 2013 Share Posted October 28, 2013 line 3 (and probably lines 1 and 2) of index.php are sending output to the browser that is preventing the session_start() from working. the reason you were not having this problem on a different server is because output_buffering was turned on in your php.ini, thereby allowing your code to function even though it is not properly organized. you need to have the session_start() statement before you send any characters of any kind to the browser (even the html doctype tag is made up of characters and must come after the session_start() statement.) Quote Link to comment Share on other sites More sharing options...
torsuntsu Posted October 28, 2013 Author Share Posted October 28, 2013 How can i solve this problem? The session_start() function is called in the init.php file like this: <?php session_start(); error_reporting(0); require 'database/connect.php'; require 'functions/general.php'; require 'functions/users.php'; if (logged_in()===true) { $session_user_id = $_SESSION['user_id']; $user_data = user_data($session_user_id,'user_id','username','password','first_name','last_name','email'); if (user_active($user_data['username'])===false){ session_destroy(); header('Location: index.com'); exit(); } } $errors = array(); ?> It´s the first thing being called, and in the other pages i include this file in the very beginning... Help...:-( Quote Link to comment Share on other sites More sharing options...
torsuntsu Posted October 28, 2013 Author Share Posted October 28, 2013 I think i solved the problem... Thanks Quote Link to comment Share on other sites More sharing options...
.josh Posted October 28, 2013 Share Posted October 28, 2013 the reason you were not having this problem on a different server is because output_buffering was turned on in your php.ini, thereby allowing your code to function even though it is not properly organized. or the error settings for warning level errors are disabled (which is more likely to be the case than output_buffering being turned on). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.