When the client requests the server, the request header will carry the local cookie. The request header contains the cookie: XXXX
Therefore, the server can see the client’s cookie. If the server wants to set a cookie for the client, it will add a set cookie in the response: XXX; the client will write it locally when it receives it, and then bring the local cookie with it the next time it requests
In fact, the cookie is issued to the client by the server during the session. When communicating with the server, the client will submit its own cookie to the server. That is to say, when the client accesses the server, it should carry its own cookie for access, so PHP can operate the client’s cookie.
In fact, the set cookie in the HTTP response header tells the browser to store a set of key value pairs in the client, and the browser will save the cookie when it sees it.
It can be obtained from the client first. document.cookie Method, can be implemented with cross domain
Because the server can access the local cookie, get the corresponding cookie and then operate
Supplement: if the server sets the cookie as read-only, then the client cannot operate.