3

我正在使用 MAMP,但我的会话有问题。我的代码在 WAMP 上运行良好,但在 MAMP 上不起作用,我不知道为什么。我查看了 phpinfo,但 MAMP 和 WAMP 之间的会话是相同的。

PHP 日志文件: [01-May-2012 12:18:28] PHP Warning: session_start() [<a href='function.session- start'>function.session-start</a>]: Cannot send session cookie - headers already sent by (output started at /Applications/MAMP/htdocs/Website/index.php:7) in /Applications/MAMP/htdocs/Website/header.php on line 2 [01-May-2012 12:18:28] PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /Applications/MAMP/htdocs/Website/index.php:7) in /Applications/MAMP/htdocs/Website/header.php on line 2

阿帕奇日志文件: [Tue May 01 12:03:29 2012] [notice] Digest: generating secret for digest authentication ... [Tue May 01 12:03:29 2012] [notice] Digest: done [Tue May 01 12:03:29 2012] [notice] Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8r DAV/2 PHP/5.3.6 configured -- resuming normal operations [Tue May 01 12:04:11 2012] [notice] caught SIGTERM, shutting down [Tue May 01 12:04:24 2012] [notice] Digest: generating secret for digest authentication ... [Tue May 01 12:04:24 2012] [notice] Digest: done [Tue May 01 12:04:24 2012] [notice] Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8r DAV/2 PHP/5.3.6 configured -- resuming normal operations [Tue May 01 12:05:11 2012] [error] [client 127.0.0.1] client denied by server configuration: /Applications/MAMP/htdocs/.DS_Store

为什么他们不工作?

谢谢你。

4

2 回答 2

3

看这里:

 headers already sent by (output started at /Applications/MAMP/htdocs/Website/index.php:7)

在该行中,在您调用之前会生成一些输出session_start()。如果您生成任何输出(即使只是换行符或其他内容,空格,您命名它),则会发送一个标头,并且您不能为session_start().

我怀疑它与您的 *AMP 有什么特别的关系。

于 2012-05-01T11:27:34.760 回答
0

我也在使用 MAMP for Mac。

我收到了与您相同的错误消息。

我通过以下方式解决了我的问题:

而不是将您的 php 放在文档的开头。把 PHP 放在前面(doctype)

I did this and the code worked.

Also, make sure the (php) tag is the first in the document. Leave no white spaces.

GL

于 2014-10-08T19:56:45.410 回答