Destroy session variables in PHP. 1. what is session? It is equivalent to an access to the server from a client (which can be a browser, app, ftp, and other clients, and several more clients can be opened in the same browser,
1. what is session?
It is equivalent to an access to the server from a client (which can be a browser, app, ftp, and other clients, and several more clients can be opened in the same browser, during this period, the server creates a unique identifier (session_id session_name), which is actually an Array (). the start and end of the Session do not start with the user name and password entered in the service, it does not end with closing the browser or refreshing the webpage.
2. destroy session variables
Program code
Session_unset ();
Session_destroy ();
?>
Session_unset ()
Releases all the $ _ SESSION variables that have been created in the memory, but does not delete the session file or release the corresponding session id.
Session_destroy ()
Delete the session file corresponding to the current user and release the session id. The $ _ SESSION variable in the memory is retained.
Note ]:
Method for deleting a session:
1. unset ($ _ SESSION ['XXX']) deletes a single session. unset ($ _ SESSION ['XXX']) is used to unregister a registered session variable. It works the same as session_unregister. Session_unregister () is no longer used in PHP5 and can be used in the cold Palace.
Unset ($ _ SESSION) is not available. it destroys the global variable $ _ SESSION and there is no feasible way to restore it. You can no longer register the $ _ session variable.
2. $ _ SESSION = array () delete multiple sessions
3. session_destroy () ends the current session and clears all resources in the session .. This function does not unset (release) the global variables related to the current session, nor delete the client session cookie. the default session of PHP is cookie-based. to delete a cookie, you must use the setcookie () function.
Return value: Boolean value.
Function description: This function ends the current session. this function has no parameters and returns true.
Session_unset () if $ _ session is used, this function no longer works. Since PHP 5 must use $ _ session, this function can be used in the cold room.
The steps for deleting a session are as follows:
① Session_start ()
② $ _ SESSION = array ()/unset ($ _ session ['XXX'])
③ Session_destroy ()
Why? It is equivalent to an access to the server from a client (which can be a browser, app, ftp, etc., and a few more open clients in the same browser ,...