PHP session_start () Error reason analysis and solution _php Tutorial

Source: Internet
Author: User
error message:Warning:session_start () [Function.session-start]: Cannot send session cache Limiter-headers already sent

Cause: If there is output before session_start (), there will be an error,

Workaround: add Ob_start () before Session_Start ();

index.php
Copy the Code code as follows:
Error_reporting (-1);
Ob_start ();//Do not add error, cannot write session
Register_shutdown_function (' close ');


Echo 1;
Session_Start ();

$_session[' password ']= ' mima2ddddddddddddddda2 ';

function Close ()
{
if (session_id ()!== ")
@session_write_close ();
}
?>
Index2

Index2. Php
Copy the Code code as follows:
Error_reporting (-1);
Ob_start ();//Do not add error, cannot read session
?
Echo 1;
Session_Start ();

echo $_session[' password '];
Var_dump ($_session);
?>
Index

http://www.bkjia.com/PHPjc/824915.html www.bkjia.com true http://www.bkjia.com/PHPjc/824915.html techarticle error message: Warning:session_start () [Function.session-start]: Cannot send session cache Limiter-headers already sent reason: Before Session_Start (), if there is output content, ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.