我用的是thinkphp框架 ,在config.php中设置了'USER_AUTH_KEY' => 'authId', 在IndexAction中用Session::set(C('USER_AUTH_KEY'),$user["id"]);设置session,以前都没什么问题,今天突然出现以下问题了,不知道什么原因,求帮助啊当前页面 : /anty/index.php模板缓存 : anty/Runtime/Cache/3789b4d0538172476372452d7396545a.php请求方法 : GET通信协议 : HTTP/1.1请求时间 : 2012-05-01 09:23:35用户代理 : Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; 360SE)会话ID : 13166fbd1c6564e52553a9e9d7b500ef日志记录 : 4条日志[ 2012-05-01T09:23:36+08:00 ] NOTIC: [2] session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at D:\www\anty\ThinkPHP\ThinkPHP.php:1) ~runtime.php 第 2 行. [ 2012-05-01T09:23:36+08:00 ] NOTIC: [2] session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at D:\www\anty\ThinkPHP\ThinkPHP.php:1) ~runtime.php 第 2 行. [ 2012-05-01T09:23:36+08:00 ] NOTIC: [2] Cannot modify header information - headers already sent by (output started at D:\www\anty\ThinkPHP\ThinkPHP.php:1) ~runtime.php 第 2 行. [ 2012-05-01T09:23:36+08:00 ] NOTIC: [2] Cannot modify header information - headers already sent by (output started at D:\www\anty\ThinkPHP\ThinkPHP.php:1) ~runtime.php 第 2 行. 加载文件 : 11[0] => D:\www\anty\index.php[1] => D:\www\anty\ThinkPHP\ThinkPHP.php[2] => D:\www\anty\anty\Runtime\~runtime.php[3] => D:\www\anty\ThinkPHP\Common\convention.php[4] => D:\www\anty\anty\Conf\config.php[5] => D:\www\anty\anty\Common\Common.php[6] => D:\www\anty\ThinkPHP\Common\debug.php[7] => D:\www\anty\ThinkPHP\Lib\Think\Util\Dispatcher.class.php[8] => D:\www\anty\ThinkPHP\Lang\zh-cn.php[9] => D:\www\anty\anty\Lib\Action\IndexAction.class.php[10] => D:\www\anty\anty\Runtime\Cache\3789b4d0538172476372452d7396545a.php
Cannot send session cookie - headers already sent by 一连出现几个这样的提示,只能说明一件事,这里肯定有问题啦.解决方案:1,回看代码,看session_start之前是否有输出.2,如果确认第一步没问题,那就可能是BOM头惹的祸了.下载个去BOM头小工具.一次把所有的代码去一次BOM头.这样,问题应该可以解决了.3,如果还是不行,那只有出狠招了.修改PHP.ini配置.把你之前的代码用替换一次把所有的session_start去掉.然后在php.ini中设置 session.auto_start设置为1,或on.
在header之前有输出,原因可能是你设置session之前有输出。像设置session的之前会session-start()一下,而在这之前不能有输出的。 追问 之前试过都可以的,后来不知道为什么不行了 ,你说的那些我网上搜到过,但都不是