Correct logoff of PHP SESSION

Source: Internet
Author: User

1 <?php 2/* 3 1, each page must be opened session_start () to use the session in each page. 4   5 2, Session_Start () initialization session, the first access will generate a unique session ID is saved on the client (is cookie-based), the next time the user accesses, Session_Start () will check that there is no session ID, If there is a browser with this session ID (sent through the sending header file, which can be seen in the FF browser) to determine the client. 6   7 3, the session that is given to the cookie will save a conversation ID of session_id on the client, which can be seen by printing a cookie, the session_id key value is Session_name, 8 session_id () = = $_cookie[session_name ()] 9  10 4, if the client has disabled cookies, the URL must be passed session_id that is to give the URL SESSION11  12 5, You can not use unset ($_session) When you log off the session, you may use $_session = Array () or $_session = null, the correct way to unregister the session is as follows: */14  15// Correct logoff session method: 16//1 Open session17 session_start ();  19//2, clear session Information $_session = Array ();  22//3, Clear Client Sessionid23 if (Isset ($_cookie[session_name ()))     (Setcookie) (Session_name (), ", Time ()-3600, '/'); 26} 27//4, Complete destruction of Session28 Session_destroy ();

Correct logoff of PHP SESSION

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.