Front knowledge

Set-cookie Response header is some information sent by the server to the browser or other clients. It is generally used to return credential information to the client after successful login. Then, the Cookie will be carried in the next request. This way the server knows which user the request is from.

Cookie request header field is the information sent when the client sends a request to the server (the browser automatically completes the request under certain conditions, without front-end code assistance)

conditions

If the following conditions are met:

  1. The domain (.a.com) field of a Cookie on the browser is equal to the requested domain name or the parent domain name of the request. The requested domain name must be a.com/b.a.com
  2. Either HTTP or HTTPS, or in different cases the Secure property is false (i.e., if Secure is true, only HTTPS requests can carry this cookie)
  3. To send a request, the path must be the same as the path attribute of the browser-side Cookie, or a subdirectory of the path of the browser-side Cookie. For example, the path of the browser-side Cookie is /test. The requested path must be /test or /test/ XXXX

The preceding three conditions must be met; otherwise, the request will not automatically carry an existing Cookie on the browser