session_start():Warning Cannot send session cookie - headers already sent... 解决方法
来源:互联网 发布:acr软件下载 编辑:程序博客网 时间:2024/04/27 06:12
在php端开启一个session时,有时候会出现很诡异的warning,Warning Cannot send session cookie - headers already sent。这个问题是因为在php session_start()之前已经有输出了。这样会导致session_start()调用失败。
- UTF-8 + BOM编码
有一种原因是文件是UTF-8 + BOM编码,这种编码方式会在普通的utf-8文件之前加三个字符。在windows下用editplus保存是会出现这个问题。我们可以用以下php代码去查看是否有BOM头,并挪掉相应的BOM头信息。
function checkBOM($filename) {global $auto;$contents = file_get_contents ( $filename );$charset [1] = substr ( $contents, 0, 1 );$charset [2] = substr ( $contents, 1, 1 );$charset [3] = substr ( $contents, 2, 1 );if (ord ( $charset [1] ) == 239 && ord ( $charset [2] ) == 187 && ord ( $charset [3] ) == 191) {if ($auto == 1) {$rest = substr ( $contents, 3 );rewrite ( $filename, $rest );echo "BOM found, automatically removed.";} else {echo "BOM found.";}} elseecho "BOM Not Found.";}
- 其他问题
我们在session_start()这个php文件中include的其他php文件第一行为空白,也会引起这个问题。
//空白<?phpsession_start(); //第一行空白,会导致错误
- session_start():Warning Cannot send session cookie - headers already sent... 解决方法
- Warning: session_start(): Cannot send session cookie - headers already sent by
- Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent
- Warning: Cannot send session cookie - headers already sent
- Warning: Cannot send session cookie - headers already sent
- 关于session_start() [function.session-start]: Cannot send session cookie - headers already sent 的解决办法
- Warning:session_start():cannot send session cache limiter -headers already sent(output started) at
- session_start()关于Cannot send session cache limiter - headers already sent错误解决方法
- php session_start()关于Cannot send session cache limiter - headers already sent 错误解决方法
- Cannot send session cookie - headers already sent by
- session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (
- Cannot send session cache limiter - headers already sent错误解决方法
- Cannot send session cache limiter - headers already sent错误解决方法
- Cannot send session cache limiter - headers already sent错误解决方法
- Warning Cannot send session cookie - headers already sent...问题的解决(PHP的UTF-8 BOM引起的问题)
- 关于php开发过程当中遇到的Cannot send session cookie - headers already sent by 问题
- PHP 错误:Cannot send session cookie – headers already sent by ..解决办法
- 关于Cannot send session cache limiter - headers already sent错误解决方法
- vim中快速的定位函数或者类定义
- C语言-程序中执行cmd命令并获取结果
- 数据结构--顺序表
- InstallShield安装与制作
- CFileFind遍历目录查找文件
- session_start():Warning Cannot send session cookie - headers already sent... 解决方法
- gsoap中文乱码问题
- MFC COMBOX使用
- NS3安装过程
- setsockopt函数的用法
- 详解CSS选择器、优先级与匹配原理
- timus 1005 stone pile
- 【android基础】android preferences
- YCbCr 转 RGB 保存成JPEG文件