Session_unset ()
Releases all $_session variables that are currently created in memory, but does not delete the session file and does not release the corresponding session ID
The code is as follows |
Copy Code |
<?php Session_Start (); Session_unset (); Session_destroy (); Session_write_close (); Setcookie (Session_name (), ', 0, '/'); SESSION_REGENERATE_ID (TRUE); ?>
|
Session_destroy ()
Deletes the session file for the current user and releases the session ID, and the contents of the $_session variable in memory remain
Therefore, releasing all resources for the user's session requires sequential execution of the following code:
The code is as follows |
Copy Code |
<?php $_session[' user '] = ' user1′; Session_unset (); Session_destroy (); ?> |
To delete the session method:
1. unset ($_session[' xxx ') deletes a single session,unset ($_session[' xxx ')) to unregister a registered session variable. The effect is the same as Session_unregister (). Session_unregister () is no longer used in PHP5, and can be put into the doghouse.
Unset ($_session) This function must not be used, it will destroy the global variable $_session, and there is no feasible way to restore it. Users can no longer register $_session variables.
2, $_session=array () Delete multiple sessions
3. Session_destroy () ends the current session and empties all resources in the session ... The function does not unset (release) the global variable (globalvariables) associated with the current session, nor does it delete the client's session cookie. PHP default session is based on cookies, and if you want to delete cookies, you must use the Setcookie () function.
Summarize:
Session_destroy is the cancellation of all the session variables and the end of sessions;
Session_unset () does not unregister the session variable, but clears the value of all session variables.