why am i getting the cannot send session cookie error on my php webpage when it is in an online webserver?
i have a perfectly working site in my local machine, which was developed using WAMP server. I tried moving it over to a webost, and i keep getting this message in my pages -
Error -
<b>Warning</b>: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent by (output started at /www/host.com/appi/htdocs/connect.php:11) in <b>/www/host.com/appi/htdocs/session-public.php</b> on line <b>5</b><br />
<br />
<b>Warning</b>: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /www/host.com/app开发者_开发问答i/htdocs/connect.php:11) in <b>/www/host.com/appi/htdocs/session-public.php</b> on line <b>5</b><br />
I have a session start to be set if not already set, in all my pages. My question is, if it works in my local machine, why this error when the same code is moved over to a shared web server online?
PHP has a lot of configuration options that allow you to configure PHP from outside of a running script. One of them is output_buffering that allows you to implicitly buffer any output before sending it to the client.
If output buffering is enabled, you can modify the HTTP header even after some output as the output is buffered and not immediately sent to the client that would implicate sending of the HTTP header before.
So it seems that your local machine has output_buffering enabled while your other server hasn’t.
精彩评论