开发者

PHP session_start() error? [duplicate]

This question already has answers here: 开发者_JS百科 Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜