Error message:Warning: session_start () [function. session-start]: Cannot send session cache limiter-headers already sent
Cause:If output content exists before session_start (), an error occurs,
Solution:Add ob_start () before session_start ();
Index. php
Copy codeThe Code is as follows:
<? Php
Error_reporting (-1 );
Ob_start (); // if this parameter is not added, an error occurs and the session cannot be written.
Register_shutdown_function ('close ');
Echo 1;
Session_start ();
$ _ SESSION ['Password'] = 'mima2ddddddddddddddddda2 ';
Function close ()
{
If (session_id ()! = '')
@ Session_write_close ();
}
?>
<A href = "index2.php"> index2 </a>
Index2.Php
Copy codeThe Code is as follows:
<? Php
Error_reporting (-1 );
Ob_start (); // if this parameter is not added, the session cannot be read.
?
Echo 1;
Session_start ();
Echo $ _ SESSION ['Password'];
Var_dump ($ _ SESSION );
?>
<A href = "index. php"> index </a>