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