Home > php教程 > php手册 > Warning: session_start() [function.session-start]: Cannot se

Warning: session_start() [function.session-start]: Cannot se

WBOY
Release: 2016-06-13 09:55:29
Original
891 people have browsed it

在很多时间使用了session就会出来如下提示了,

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/u114264/include/db_mysql教程.class.php教程:1) in /home/u114264/login1.php on line 3

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/u114264/include/db_mysql.class.php:1) in /home/u114264/login1.php on line 3

分析最大的可能是在session_start()前面有字符输出包括空格 ,只要处理就好了,

还有一种方法直接给session_start()加上@session_start()就没事了。不推荐

地址解决方案。


最通常的解决方案。打开output_buffering = 4096;  全局性质。

 

第二种解决方案。


ob_start :打开输出缓冲区
函数格式:void ob_start(void)
说明:当缓冲区激活时,所有来自PHP程序的非文件头信息均不会发送,而是保存在内部缓冲区。为了输出缓冲区的内容,可以使用ob_end_flush()或flush()输出缓冲区的内容。
 

注意的地方:


如果使用utf-8编码,一定要去掉UTF-8中的BOM,这都是因为utf-8编码文件含有的bom原因,而php4,5都是不支持bom的。去掉bom,可以用Notepad++打开转换一下。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template