0
votes

I am trying to create a register and login page. When attempting to upload the code to our servers, it creates two errors:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/tisun_search/index.php:52) in /Applications/XAMPP/xamppfiles/htdocs/tisun_search/functions.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /Applications/XAMPP/xamppfiles/htdocs/tisun_search/index.php:52) in /Applications/XAMPP/xamppfiles/htdocs/tisun_search/functions.php on line 2

I've tried inspecting the problem in the functions.php file, there are no whitespaces nor any visible errors.

I was wondering if anyone would happen to know any other reason why this error may be occuring and what may be the solution to fix this error.

Below is the beginning of my functions.php code (Without the php tags).

session_start(); 

function loggedin() 
{
if(isset($_SESSION['user_id']) && !empty($_SESSION['user_id']))
{
return true;
    }
    else
    {
    return false;
    }
}

The code below shows where the error is occurring

1

1 Answers

0
votes

The only way to fix that, is walking through all includes and check whether they are either doing some output (echo, printf) or, most common, in a pure include (classes etc) you have spaces and NL after the final closing ?>:

....
} // end of class xyz

/*
 * some comments
 */
············¶
?>·················¶
¶
¶
¶
¶
<--- EOF

NLs might not be an issue but trailing spaces and NLs. Once you're using Eclipse, you can configure it to automatically remove these artifacts.