Session_start () logic

Source: Internet
Author: User

// Session_start-start new or resume existing session

Session_start ();

Print_r ($ _ session );


// Check whether there is a session object. If there is a PHPSESSID in the request header, the key => No cookie for the value pair. If yes, you can use this ID to check whether the session object corresponding to the ID can be found.

// Normally, if the server receives PHPSESSID, the session exists.


The request header does not have a cookie with the PHPSESSID key => value, indicating that the server does not have a session object, create a session object (and write the key => value pair in the Set-cookei of the response header to notify the browser to save the session ID locally, you do not need to create a session object when you enter the page next time in the same session ,)



// You cannot manually delete the PHPSESSID saved by the session object in the browser. (If you can manually delete the session object, you want to create many $ _ Session ultra-global arrays on the server. The server certainly does not agree, you want to delete PHPSESSID before session_start (). For the same session, a new session object will be created next time,

Setcookie (PHPSESSID, "", time ()-100 );
Session_start ();

No, PHPSESSID can only be deleted by the server, so that the uniqueness of the $ _ session variable can be ensured in a process.


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.