Error message: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent
Cause: If there is output content before session_start(), an error will occur,
Solution: Add ob_start() before session_start();
index.php
Copy code The code is as follows:
error_reporting(-1);
ob_start();//If you don’t add it, an error will occur and the session cannot be written.
register_shutdown_function('close');
echo 1;
session_start();
$_SESSION['password']='mima2ddddddddddddddda2';
function close()
{
if(session_id()!=='')
@session_write_close();
}
?>
index2
index2.Php
Copy code The code is as follows:
error_reporting(-1) ;
ob_start();//If you don’t add it, an error will occur and the session cannot be read.
?
echo 1;
session_start();
echo $_SESSION['password'] ;
var_dump($_SESSION);
?>
index
http://www.bkjia.com/PHPjc/824915.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/824915.htmlTechArticleError message: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent Reason: If there is output content before session_start(),...