Lately I've been seeing this error in my log files
[Thu Apr 05 06:33:05 2012] [error] [client 66.249.67.42] PHP Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/username/public_html/brittanycod.html:6) in /home/username/public_html/news/index.php on line 22
[Thu Apr 05 06:33:05 2012] [error] [client 66.249.67.42] PHP Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/username/public_html/brittanycod.html:6) in /home/username/public_html/news/index.php on line 22
The ip address belongs to googlebot and when I googled for help some of the solutons were to make sure there is nothing else trying to output to the browser or white space before the
session_name('n13news');
if(!isset($_SESSION)){
session_start();
}
When I open news/index.php and look at lines 19-24 I see
ob_start();
session_name('n13news');
if(!isset($_SESSION)){
session_start();
}
ob_end_clean();
there is a white space above the obstart(); and it looks like obstart(); is calling to the browser so I am assuming this is my problem. I've removed the empty space but it didn't resolve the log errors. I know very little about php so thought I see if I could get help here to see if this is normal with the script or maybe a bug?
The only reason I can think for this error to happen is if you're using the news script along with another script that uses sessions, if either of them outputs any information to the browser before the other is executed you'll get the error messages you're seeing in the log. These errors aren't critical, the script will still function when these errors do happen.
Yes I also have crafty syntax live help running also so that could be the culprit. Good to know that it is not a critical error, but it would be nice to learn how to remedy the error. I'll keep looking.