Php's understanding of cookies and Sessions: cookies are a gift (small dessert) left by the server to the client ), specifically, when a user logs on to the server, the server saves some php's understanding about cookies and sessions in the browser of the client through the setCookie function.
Cookie comprehension:
Cookie is a gift (small dessert) left by the server to the client to complete the server's authentication of the user.
Specifically, when a user logs on to the server, the server uses the setCookie function in the browser of the client.
It contains some identification data (user name, password, logon or not ). Wait until the same user accesses the site
In other web pages, the server will determine whether the behavior of the same user is based on the data.
In addition, the key function setCookie () is used to reuse cookies. Therefore, the cookie application is quite simple.
Session comprehension:
The first note is that session is a verification method for saving personal information on the server side, but there is also a way to connect with the client.
So there are two different url-based and cookie-based session methods.
Session_start ()
Session_id ()
$ _ SESSION
The functions of these numbers are fully understood.
When session_start () is executed, the value of session_id () is generated; otherwise, echo session () is output; no result is returned.
In addition, the value in the $ _ SESSION created at this time, for example, $ _ SESSION ["name"] = "zhangsan"; $ _ SESSION ["age"] = 23;
These values will be associated with session_id (), for example, members in a group.
When you jump to another interface, the first step is to execute session_start ().
At this time, the system will determine whether there is an existing session_id. if there is and the same as the previous one, then the current $ _ SESSION
The value in the array is still a member of the original group. If the system does not find session_id, sorry, I have to create another
Session_id, but this is another group. it has nothing to do with the original session_id or $ _ SESSION. Based on this idea
Understanding the cookie-based or url-based session will make you better understand ^ _ ^ |
I recommend an article to help you understand the http://www.jz123.cn/text/196.html.