PHP - Warning: session_start(): Cannot send session cookie & Cannot send session cache limiter 错误解决方案

 最近的一个PHP项目Annotation tool中,在开发环境Windows下一切正常,而在Linux下配置环境的时候运行出错,得到以下错误提示:

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/html/annotation/logincheck.php:11)
in /var/www/html/annotation/logincheck.php on line 34

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/html/annotation/logincheck.php:11)
in /var/www/html/annotation/logincheck.php on line 34

 和国外的朋友讨论了一下,应该是特殊字符或编码的问题,临时解决方法如下:

you need to add this to the top:
<? ob_start(); ?> 
and add this to the bottom:
<? ob_flush(); ?>

在出现问题的PHP文件头前加<? ob_start(); ?>  ,文件末尾加<? ob_flush(); ?> .

OK, 问题解决。

引用通告地址: 点击获取引用地址
评论: 0 | 引用: 0 | 阅读: 1284 | 打印 | 打包 | 转发
发表评论
昵 称: 密 码:
网 址: 邮 箱:
验证码: 验证码图片 选 项:
头 像:
内 容:
  • 粗体
  • 斜体
  • 下划线
  • 插入图像
  • 超链接
  • 电子邮件
  • 插入引用