The destruction of the PHP session variable

Source: Internet
Author: User
Tags session id php session
1. What is a session?

The equivalent of a client (can be browser, app, FTP and other, and the same browser open a few more different client) to a server access, this period of time the server to establish a unique identifier (session_id session_name), The session is actually an array of arrays (), the beginning and end of thesession does not start with the business input username password, and does not close the browser and page refresh and the session ends

2.session Destruction of variables

<?phpsession_unset (); Session_destroy ();? >
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
Session_destroy ()//delete the current user's session file and release session ID, the contents of the $_session variable in memory remain

"Note":

To delete the session method:

1, unset ($_session[' xxx ']) delete a single session,unset ($_session[' xxx ') to unregister a registered SESSION variable. Its effect is the same as Session_unregister (). Session_unregister () is no longer used in PHP5 and can be limbo.

Unset ($_session)//This function must not be used, it will destroy the global variable $_session, and there is no viable way to restore it. Users can no longer register $_session variables.

2, $_session=array () Delete more than one SESSION

3. Session_destroy () ends the current session and empties all resources in the session. The function does not unset (releases) the global variables associated with the current session (GlobalVariables), nor does it delete the client's session cookie. PHP's default session is cookie-based, and if you want to delete a cookie, you must use the Setcookie () function.

  Return value: A Boolean value.

Function Description: This function ends the current session, this function has no parameters and the return value is True

Session_unset () If $_session is used, the function no longer works. Since PHP5 is bound to use $_session, this function can be limbo.

The steps to delete the session can be drawn:

①session_start ()

②$_session=array ()/unset ($_session[' xxx ')

③session_destroy ()

Related recommendations:

Correct logoff of PHP SESSION, logoff phpsession_php tutorial

PHP use the session to prevent page repeat refresh, phpsession prevent page _php tutorial

PHP through the session anti-URL attack method, phpsession anti-url_php tutorial

Related Article

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.