PHP session_start() error? [duplicate]
Possible Duplicate:
PHP headers already sent
So I just joined Hostgator.com, and was wondering, why do I always get this error:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/kapip/public_html/main/mainpage.php:5) in /home/kapip/public_html/main/mainpage.php on line 7
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/kapip/public_html/main/mainpage.php:5) in /home/kapip/public_html/main/mainpage.php on line 7
What does this mean? I know I have to probably edit the php.ini, but I'm not sure what to change. Can anyone help me out? Thank you!
Make sure you don't have any whitespace or anything else displayed before you do session_start()
e.g.
// whitespace, any mark up or include that displays something <HERE>
// it will give you that error
<?php
session_start();
This is a common problem. The call to session_start must happen before the first HTML tag or echo statement.
Incorrect:
<html>
<?php session_start() ?>
Correct:
<?php session_start() ?>
<html>
Headers cannot be sent after output has started. Therefore, you should check /home/kapip/public_html/main/mainpage.php
line 5 (which was indicated by the error message) for anything that results in output.
精彩评论