Headers that appear with session_start

Source: Internet
Author: User
Warning: Cannotsendsessioncookie-headersalreadysentby (outputstartedatF: php2000testphp: 2) inF: php2000testphponline4Warning: Cannotsendsessioncachelimiter-headersalr

See detailed error programs and output results

  1.  
  2. Echo "testing ...";
  3. Session_start ();
  4. ?>
  5.  

The output is

  1. Testing...
  2. Warning: Cannot send session cookie-headers already sent by (output started at F: php2000test. php: 2) in F: php2000test. php on line 4
  3. Warning: Cannot send session cache limiter-headers already sent (output started at F: php2000test. php: 2) in F: php2000test. php on line 4

Analysis:The main reason is that session is defined in php. ini. cookie is used by default.

[Session]

Session. use_cookies = 1; whether to use cookies

This statement indicates that the use of cookies to store sessions and the setting of cookies must be performed before the official htm, that is, only in the header. Therefore, if this error occurs, we modify the program:

  1. Echo "testing ...";
  2. Session_start ();
  3. ?>

The same error occurs because echo has already been output.

  1. $ I = 1;
  2. Session_start ();
  3. ?>

Running properly indicates that there can be a computing statement before session_start, but no output statement. I tried to modify it:

  1. Session. use_cookies = 0; whether to use cookies

But it failed. a friend who wants to know the answer will inform me how to remove the cookie-based session.

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.