Explanation of path and domain attributes in cookies _ jquery-js tutorial

Source: Internet
Author: User
This article mainly analyzes and introduces the path and domain attributes in cookies in detail. If you need them, please refer to them and hope to help you. 1. domain indicates the domain where the cookie is located. The default value is the request address. For example, if the website address is www.jb51.net/test/test.aspx, then domainmask is www.jb51.net. For cross-origin access, if the domain A is t1.test.com and the domain B is t2.test.com, you must set the domain of the cookie to .test.com to generate A cookie that can be accessed by domain A and domain B in domain; to generate A cookie in domain A that makes domain A inaccessible and domain B accessible, set the domain of the cookie to t2.test.com.

2. path indicates the directory where the cookie is located. asp.net is/by default, which is the root directory. The directory on the same server is/test/,/test/cd/,/test/dd/, and the path of cookie1 is/test /, if the path of cookie2 is/test/cd/, all the pages under test can access cookie1, while the subpages of/test/AND/test/dd/cannot access cookie2. This is because the cookie allows the page under its path to access.

3. the browser will save cookies with the same domain and path in one file, and use * to separate cookies.

4. cookie with a value Key-value Pair: Previously, the cookie with a nam = value single key-value pair was used. Once it was said that the cookie with multiple sub-key-value pairs was lost. Now I have figured it out. The cookie format containing multiple child 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 string, where the key-Value Pair Delimiter is &, of course, you can define a separator, however, asp.net is used as the separator.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.