PHP session tracking and File Processing System (43 ),

Source: Internet
Author: User
Tags php session

PHP session tracking and File Processing System (43 ),
Cancel variable

1. unset ($ _ SESSION ['xxx']) deletes a single session variable. 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.
Note: The unset ($ _ SESSION) function is never 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 session Variables
3. session_unset () deletes all session variables.

Destroy session

Session_destroy () ends the current session and clears all resources in the session. This function does not unset (release) global variables related to the current session, nor delete the client session cookie.
Return Value: Boolean value.
Function Description: This function ends the current session.
No parameter, and the return value is true,

Note: The default session in PHP is based on cookies. to delete a cookie, you must use the setcookie () function.

Delete a session

<? Php // initialize session. session_start ();/* Delete all session variables .. You can also delete unset ($ _ SESSION ['xxx']) one by one. */$ _ SESSION = array (); // or session_unset ();/* Delete sessinid. because the session is cookie-based by default, setcookie is used to delete the cookie containing the session id. */if (isset ($ _ COOKIE [session_name ()]) {setcookie (session_name (), '', time ()-42000 ,'/');} // Finally, the session is completely destroyed. session_destroy ();?>
Persistent session

After the request ends, all the registered variables will be automatically serialized (to facilitate the storage to the session text file on the server side) and restored upon reading.

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.