DWQA QuestionsCategory: Development ToolCookie is client-side, so why can PHP operate client-side cookie?
And the goddess. Mm-hmm asked 8 months ago

Cookie is client-side, so why can PHP operate client-side cookie?

8 Answers
without answered 8 months ago

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

Chestnut boom answered 8 months ago

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.

mokeyWie answered 8 months ago

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.

Set-Cookie:key=value;...
Tofu resident answered 8 months ago

HTTP protocol

arsenal answered 8 months ago

It can be obtained from the client first. document.cookie Method, can be implemented with cross domain

Swimming fish answered 8 months ago

Because the server can access the local cookie, get the corresponding cookie and then operate

pursue answered 8 months ago

Supplement: if the server sets the cookie as read-only, then the client cannot operate.

u_ Village leader answered 8 months ago

The server tells the client to set the cookie locally… Naturally, you can tell the client to modify or delete the cookie