Session-What is the difference between a cookie sent by a browser HTTP request and a cookie in the PHP setcookie function?

Source: Internet
Author: User
Tags send cookies
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.