: This article mainly describes how to cancel the PHPSESSION correctly. For more information about PHP tutorials, see.
/* 1. you must enable session_start () on each page before using session on each page. 2. session_start () initializes the session. during the first access, a unique session ID is generated and saved on the client (saved based on cookies). during the next access, session_start () check whether there is a session ID. if there is a browser that will bring this session ID (this can be seen in ff browser by sending the header file) to determine the client. 3. the session sent to the cookie will save a session ID (session_id) on the client. you can print the cookie to see that the key value of this session_id is session_name and session_id () ==$ _ COOKIE [session_name ()] 4. if the cookie is disabled on the client, you must use the url to pass the session_id, that is, the SESSION5 given to the URL. when you cancel a SESSION, you cannot use unset ($ _ SESSION). you can use $ _ SESSION = array () or $ _ SESSION = null, the correct method for canceling a session is as follows: * // the correct method for canceling a session: // 1 enable sessionsession_start (); // 2. clear the session information $ _ SESSION = array (); // 3. clear the client sessionidif (isset ($ _ COOKIE [session_name ()]) {setCookie (session_name (), '', time ()-3600, '/');} // 4. completely destroy sessionsession_destroy ();
The above describes how to correctly log out of the php session, including related content, and hope to help those who are interested in the PHP Tutorial.