In learning PHP, sessions are what we often use, so today we will talk about sessions in details in detail; 1. Working mechanism of session: When the session is opened, the server will save the session file in the server, and then save the session ID number in the browser to obtain the corresponding session information; 2. The following is the focus of the article: transferring session based on URL If the session is transmitted according to 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 number on the link address of the website, so that we are not afraid of the user turning off the cookie! (We take simple user login as an example. When the user turns on cookies, it is transmitted by cookie, and when the user turns off cookies, it is transmitted by URL) 1. Create a user login page and add after the action address of the form. SID When the user turns on cookies, the output is empty 2. Create a page to determine whether the user is logged in; When session_id() contains parameters, it means to use the id in the parameters as a reference to find the sessoin file. Note that session_id() must be in front of session_start() 3. Create a logout page First clear the current user’s session data, and then delete the user’s session file This whole small case of session transmission based on URL is done! ! The above is the entire content of this article, I hope you all like it. |