Jump to content

Warning apears i don´t know why


torsuntsu

Recommended Posts

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

Link to comment
Share on other sites

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.)

Link to comment
Share on other sites

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...:-( 
Link to comment
Share on other sites

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).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.