Does the $_cookie variable get the value of a cookie by reading a cookie file?
Why does the value of the $_cookie variable exist after the cookie file is deleted?
Reply content:
Does the $_cookie variable get the value of a cookie by reading a cookie file?
Why does the value of the $_cookie variable exist after the cookie file is deleted?
The process of creating a cookie is this: after the server sets the cookie, it returns to the browser, and the browser stores the cookie locally on the client, and every time the browser requests an HTTP request to the server, the cookie will be taken, and if the client deletes the cookie, The cookie in the request sent to the server is empty, and you can observe the cookie field in the Requuest_header of the browser console
session_start();var_dump($_COOKIE);
The above two lines of code open the session. Open Chrome Developer mode
So I tried to kill the cookie.
A new session. There's 一个sessionID 可以认为是一个会话
no connection between sessions.
And $_COOKIE
This is a system variable. Can Baidu PHP system variables. Several, each variable is what, what division of labor and responsibility, this can go to explore under.
is the header of the user request, each request will be taken,
Strictly speaking not by reading the file.
When the browser sends the request, it will include the cookie in the request:
The server side then parses the cookie header and coexists to the $_cookie variable.
But I don't know what your so-called Delete cookie file is exactly. Since the cookie file was deleted, the equivalent of the cookie being emptied, the $_cookie should be empty when the browser immediately sends the request.
The front end can set the cookie value, and when sending an HTTP request, the cookie value is sent to the server side
The server is logging or validating data by reading the header information of the HTTP request, or setting a new cookie
After receiving the reply from the HTTP request, the client will bring the cookie value back to the Set-cookie
The browser then saves the cookie to the local cookie file ~ ~ ~
Deleting a local cookie file does not mean that there is no cookie information when sending the request, depending on whether the front end is setting a cookie for this request
If it is set up, the request will still be sent to the server, the server can still receive ~ ~ ~