- 时间:2022-07-06 22:06 编辑: 来源: 阅读:
- 扫一扫,手机访问
摘要:php session_start()出错原因分析及解决方法
[b]
错误提示:[/b] Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent
[b]
原因:[/b]在session_start()之前如果有输出内容,会出错,
[b]
解决办法:[/b]在session_start()之前加上ob_start();
[b]index.php
[/b]
[url=index2.php]
[b]index2.Php
[/b]
<?php
error_reporting(-1);
ob_start();//不加会出错,无法读取session
?
echo 1;
session_start();
echo $_SESSION['password'];
var_dump($_SESSION);
?>
<a href="index.php" >index</a>