PHP session title highlights solution plan

Source: Internet
Author: User
The session function of PHP has always been difficult for many beginners. Some veterans are sometimes confused. This article provides a brief summary of these titles for your reference. 1. Warning: Cannotsendsessioncookie: The session function of PHP has always been difficult for many beginners. Some veterans are sometimes confused. This article provides a brief summary of these titles for your reference.

1.
Error message
Warning: Cannot send session cookie-headers already sent
Warning: Cannot send session cache limiter-headers already sent
Analysis and solutions
The reason for this type of title is that when you apply session_start () in the program, the actual html content is output. Maybe you said, I didn't. I just echo or print a message. Negative. the output produced by your echo or print statement is the actual html content output. The solution to this type of title is to adjust your session_start () to the first line of the program.

2.
Error message
Warning: open (F:/689 \ php \ sessiondata \ sess_66a39376b873f4daecf239891edc98b5, O_RDWR) failed
Analysis and solution
The error statement is displayed because the session. save_path item in your php. ini is not set. the solution is to set session. save_path and session. cookie_path
Session_save_path = c: \ temp
Session. cookie_path = c: \ temp
Create a temp directory under the c: \ directory.

3.
Error message
Warning: Trying to destroy uninitialized session in
Analysis and solution
Generally, you directly call the session_destroy () function. Many friends think that the session_destroy () function can run independently. The solution is to enable the session function with session_start () before you call the session_destroy () function.

4. Title: how to obtain the id of the current session?
The simplest method is:
Echo SID;
You will invent it.

5. title: my program has no output before calling the header function, although I include a config. php file, but in config. there is no output in the PHP file. Why does the session still report the same error as the header 1? is it because I used session_start () before the header?
A: Maybe you have carefully checked your php program. there is no output before header () is referenced, and there is no output in your include file! But are you using the mouse key?> What about the mobile check after the conclusion of this PHP code? So you will invent it?> There is a blank line or space behind this. if you delete these blank lines or spaces, the title will be resolved.
Note: This title is displayed in PHP4.1.2 and later versions. it has not been tested.

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.