PHP's understanding of the cookie and session
For the understanding of cookies:
A cookie is a way that the server leaves the client with a gift (a small dessert) to complete the server's authentication to the user.
Specifically, when the user logs on to the server, there is a server through the Setcookie function in the client's browser
There are some data (user name, password, login or not) that can be identified. Wait until the same user accesses the site
Other pages, the server will determine whether the same user behaves according to the data.
In addition to the use of cookies when a key function Setcookie (); So the application of cookies is quite simple.
For the session Understanding:
The first explanation is that the session is a verification method to keep personal information on the server side, but there is a means to connect with the client
, so there are two different conversational approaches based on cookies and URLs.
Session_Start ()
SESSION_ID ()
$_session
The role of these numbers is fully understood.
The value of session_id () is generated when the session_start () is executed, otherwise the echo session is output ();
In addition, the values created at this time are $_session, such as $_session["name"]= "Zhangsan"; $_session["age"]=23;
These values will be together with session_id (), like members in a group.
When jumping to another interface, the first step is to execute session_start ().
At this point the system will determine whether there is an existing session_id, if there is and the same as the previous one, so good, the current $_session
The values inside the array are still members of the original group. Idea if the system didn't find session_id, then I'm sorry, I have to create another
session_id But this is the other group, with the original session_id or $_session has no relationship, according to this idea
Understanding a cookie or URL-based session will make you understand ^_^ | |
I would like to recommend an article to you to help understand the http://www.jz123.cn/text/196.html