Client--------->1.request------------------------->server
2. Session_Start (); |<-------------3.reponse (session_id) <--------| |-------------> 4.request (session_id)--------->| 5. Session_Start (); |<-------------6.reponse (session_id) <---------| |------------- >7. Request (session_id + logout)-->| 8. Session_destroy (); |<-------------9. Reponse (Delete cookie file) <-------| 1. The client opens the Web page and makes a request to the server, and the client does not deliver the session_id 2 in the request because there is no corresponding cookie file. After receiving the client request, the server starts the session processing by executing the session_start () function, first confirming that there is no session_id in the request and, if not, issuing a new session_id; The session_id file is called, and the information is written to the $_session and deposited in a file beginning with Sess_. 3. The $_session parameter that writes the message is sent back to Client,client after the information sent by the get server, and the information is stored in a cookie. 4. The client writes the session_id in the cookie to the header and then to Ser again.Ver makes a request. Repeat 1-3 of the operation 7. Client issues a logout request 8. After the server accepts the request, it begins by executing the Session_destroy () function to delete session file processing 9. The server sends a command to the client to delete the cookie file stored on the client: Setcookie (Session_name (), ", Time ()-60, '/');
How the session works