当我的 php 网页位于在线网络服务器中时,为什么我会收到无法发送会话 cookie 错误?
我的本地机器上有一个完美工作的网站,它是使用 WAMP 服务器开发的。我尝试将其移至 webost,并且我不断在我的页面中收到此消息 -
错误 -
<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/appi/htdocs/connect.php:11) in <b>/www/host.com/appi/htdocs/session-public.php</b> on line <b>5</b><br />
我在所有页面中开始设置会话(如果尚未设置)。 我的问题是,如果它在我的本地计算机上运行,为什么当将相同的代码移动到在线共享网络服务器时会出现此错误?
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/appi/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 有很多配置选项,允许您从正在运行的脚本外部配置 PHP。其中之一是 output_buffering< /a> 允许您在将任何输出发送到客户端之前隐式缓冲它。
如果启用输出缓冲,则即使在某些输出之后,您也可以修改 HTTP 标头,因为输出已被缓冲,并且不会立即发送到客户端,这意味着之前已发送过 HTTP 标头。
因此,您的本地计算机似乎已启用output_buffering,而您的其他服务器尚未启用。
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.