What is the difference between a cookie sent by a browser HTTP request and a cookie in the PHP setcookie function? Are the two cookies visible in the browser-"Web page information-" Display website cookie?
Reply content:
What is the difference between a cookie sent by a browser HTTP request and a cookie in the PHP setcookie function? Are the two cookies visible in the browser-"Web page information-" Display website cookie?
The cookie set by Setcookie will be hhtp in the form of a response header, written to the browser, and, if path,domain, etc., will be added to the HTTP request header the next time the HTTP request is sent. They are only set differently, but once set, they can be seen in the browser developer tool.
can refer to a question I have answered before http://segmentfault.com/q/1010000002655809/a-1020000002655842
PHP Setcookie function, is to inform the browser, to save this cookie, browser HTTP request sent by the cookie is the previous saved cookie sent to the server, tell the server, I have this cookie.
In fact, you first have to understand the role of cookies, he is the server generated after the client, to verify the identity of the user. This way the client (browser) sends the cookie to the server when the request is sent to the server, so that the service side just checks to see if your cookie is right, so you don't have to check the user's account password every time. (Of course, cookies have other effects, such as storing the user's access habits, and so on).
And for your problems,
Client (browser): The cookie sent by the HTTP request is the server generated and sent to the browser, browsing every time to send requests to the server to carry back.
Server: PHP Setcookie is actually the process of generating cookies on the server.
Both are the same thing. So what you see in the browser is the same thing.
1 A cookie is a unified standard, and in what way it should be the same, otherwise it loses its meaning.
2 browsers do not send cookies, so there is no "browser HTTP request sent cookies", are sent from the server side to the browser, because HTTP is a stateless protocol, only use cookies and session to identify a user's identity.