Use URL to transmit SESSION information and url to transmit session information
In php learning, sessions are often used. Today we will talk about sessions in detail;
I. session working mechanism:
When the session is enabled, the server saves the session file on the server, and then saves the session ID in the browser to obtain the corresponding session information;
II. The following is the focus of the article: transmitting sessions based on URLs
If the session is transmitted using the basic session method, the cookie in the user's browser will be used. Once the user closes the cookie, the session will not work! So next we will put the session ID on the link address of the website, so that users are not afraid to close the cookie!
(We use simple user logon as an example. When a user enables a cookie, the cookie is transmitted as a cookie. When the cookie is disabled, the cookie is transmitted as a url)
1. Create a user logon page and add
SID: When the cookie is enabled, the output is empty.
SID: When the cookie is disabled, the current user's session information is output. The specific format is session_name = session_id;
2. Create a logon page to determine whether a user is logged on;
Session_id () indicates that the sessoin file is found based on the id in the parameter. Note that session_id () must be before session_start ().
3. Create an exit logon page
First, clear the session data of the current user, and then delete the session file of the current user.
This is a small case of url-based session transmission !!
The above is all the content of this article. I hope you will like it.