Home > Web Front-end > JS Tutorial > Detailed explanation of path and domain attributes in cookies_jquery

Detailed explanation of path and domain attributes in cookies_jquery

WBOY
Release: 2016-05-16 17:08:38
Original
1656 people have browsed it


1.domain represents the domain where the cookie is located. The default is the requested address. For example, if the URL is www.jb51.net/test/test.aspx, then the domain defaults to www.jb51.net. For cross-domain access, if domain A is t1.test.com and domain B is t2.test.com, then to produce a cookie in domain A that both domain A and domain B can access, the domain of the cookie must be set to .test.com; If you want to produce a cookie in domain A that domain A cannot access but domain B can access, you must set the domain of the cookie to t2.test.com.

2.path indicates the directory where the cookie is located. The default for asp.net is /, which is the root directory. There are directories on the same server as follows: /test/,/test/cd/,/test/dd/. Now suppose the path of cookie1 is /test/, and the path of cookie2 is /test/cd/, then under test All pages can access cookie1, but the subpages of /test/ and /test/dd/ cannot access cookie2. This is because the cookie allows the page under its path to be accessed.

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

4. Cookies containing value key-value pairs: I have been using cookies with nam=value single key-value pairs in the past. When it comes to cookies containing multiple sub-key-value pairs, I am confused. Now I finally have it figured out. The cookie format containing multiple sub-key-value pairs is name=key1=value1&key2=value2. It can be understood that the value of a single key-value pair saves a custom multi-key value string, in which the key-value pair separator is &. Of course, you can customize a separator, but when obtained with asp.net, it is separated by &. symbol.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template