Warning: session_start() [function.session-start]: Cannot send session cache limiter解决方法

时间:2016-07-27
在使用session_start()的时候出现这个错误Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at D:\xampplite\htdocs\test\conn.php:1) in D:\xampplite\htdocs\test\login.php on line 8

错误提示: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent

原因:在session_start()之前如果有输出内容,会出错,

解决办法:在session_start()之前加上ob_start();

<?php 
error_reporting(-1); 
ob_start();//不加会出错,无法写入session 
register_shutdown_function('close'); 

  
echo 1; 
 session_start(); 

$_SESSION['password']='mima2ddddddddddddddda2'; 
/* http://www.manongjc.com/article/1270.html */
function close() 
    { 
        if(session_id()!=='') 
            @session_write_close(); 
    } 
?> 
<a href="index2.php" >index2</a> 

上一页 下一页

原文地址:http://www.manongjc.com/article/1270.html