会话不适用于MAMP [英] Sessions don't work on MAMP
问题描述
我正在使用MAMP,但是会话有问题.我的代码可以在WAMP上完美运行,但不能在MAMP上运行,我也不是为什么.我查看了phpinfo,但是MAMP和WAMP之间的会话相同.
I'm using MAMP, but I have a problem with session. My code works perfectly on WAMP, but doesn't work on MAMP and I don't no why. I looked the phpinfo but there are the same for the session between MAMP and 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
PHP log file :
[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
Apache日志文件:
[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
Apache log file :
[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
为什么它们不起作用?
谢谢.
推荐答案
查看此处:
headers already sent by (output started at /Applications/MAMP/htdocs/Website/index.php:7)
在调用session_start()
之前,该行中的
会生成一些输出.如果您生成任何输出(甚至只是换行符或其他东西,用空白命名),则将发送一个标题,并且您将无法发送session_start()
的另一个标题.
in that line there is some output generated before you call session_start()
. If you generate ANY output (even just a newline or something, whitespace, you name it) a header gets send and you cannot send another header for session_start()
.
我怀疑这与您的* AMP有什么特殊关系.
I doubt it has anything specifically to do with your *AMP.
这篇关于会话不适用于MAMP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!