Path and domain properties in cookies

  • 2020-03-30 00:58:11
  • OfStack

1. The domain is a cookie in the domain, the default for the request of address, such as, then the domain to by default. For cross-domain access, if domain A is and domain B is, then to produce A cookie accessible to both domain A and domain B in domain A, the domain of the cookie should be set to. If you want to produce A cookie in domain A that is inaccessible to domain A but accessible to domain B, set the domain of that cookie to

2. Path represents the directory where the cookie is located. defaults to /, which is the root directory. On the same server directory as follows: / test /, /, / test/CD/test/dd, now set a path for the/test /, cookie1 cookie2 path for the/test/CD /, so the test of all pages can be accessed to cookie1 / test/and/test/dd/child pages cookie2 can be accessed. This is because cookies allow pages in their path to be accessed.

3. The browser will save cookies with the same domain and path in a file, and the cookies are separated by *.

4. Cookie with value key value pair: previously, the cookie with nam=value single key value pair was always used, and the cookie with multiple child key value pairs was ignored. Now I know. The cookie format with multiple child key-value pairs is name=key1=value1&key2=value2. The value of a single-key-value pair can be interpreted as a custom multi-key-value string, where the key-value pair is delimited by an &. You can, of course, customize a delimiter, but you get it with with an & as the delimiter.


Related articles: