教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php使用session提示Cannot send session cache

php使用session提示Cannot send session cache

发布时间:2016-10-22   编辑:jiaochengji.com
教程集为您提供php使用session提示Cannot send session cache等资源,欢迎您收藏本站,我们将为您提供最新的php使用session提示Cannot send session cache资源
在php页面加服务器端用户验证时碰到使用session页面出现Warning: session_start() [function.session-start]: Cannot send session cache limiter...错误了,在网上看了一圈发现方法很简单。

今天在使用php 的session 的时候,出现了如下提示:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started ..

因为在session_start(); 语句之前有其他的html代码

解决办法:

修改php.ini中的session.auto_start = 0 为 session.auto_start = 1


设置变量

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy8097')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy8097>

session_register("user");
$_SESSION["user"]=$name;

获取

session_start();
echo $_SESSION["user"];

如果上面还是无法解决我们可以看看是不是编码问题。

1、将出错档案转换为 UTF-8 编码无 BOM 格式(我一般是用 Notepad 来转)
2、以 ob_start() 开启缓?区将输出资讯写入缓?区,可避免 headers 先于 session_start() 输出

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy6469')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy6469>

<?php
ob_start()
echo "test"
session_start()
ob_end_flush()
?>

补充有朋友说:session.save_path = "C:/phpsession" [后边的路径自己设置,并且要保证存在,其实这个是错误的了我们配置好php时就己经配置好了,如果其它程序没有问题千万不要去修改session.save_path保存路径了。

您可能感兴趣的文章:
php Cannot send session cache limiter
Warning: session_start() [function.session-start]
session Cannot send session cache limiter 错误提示
php使用session提示Cannot send session cache
php提示”Cannot send session cache limiter
Warning: session_start(): Cannot send session
我学PHP--关于session_start()
php使用session时出现的报错
关于Session的问题集锦解决方案
关于使用 session_start 出现的 headers 

[关闭]
~ ~