Implementation of second-level domain names or cross-domain Cookies sharing _ javascript skills

Source: Internet
Author: User
Tags subdomain subdomain name
Applicable to Asp. Cookies set for the primary domain name are shared with each subdomain name. They are applicable to second-level domain names such as blogs. This problem is solved by having many posts on the Internet. Note:
1. When you have a Cookie group (or Cookie dictionary) that uses the Domain attribute to specify a Domain name, when you modify or add new members to the group, you must add Resonse after the operation. cookies (cookieName ). domain attribute.
2. If you do not need to modify the Cookie Group of the Domain, use Response. Cookies ("CookieText") = CookieValue to create a new Cookie. For each independent Response. Cookies ("CookieText"), all data is written in one time regardless of the dictionary. If you need to write data multiple times, change to Response. Cookies ("CookieText "). This is important.
3. Response. Cookies ("cookieName"). Secure = False. The Secure attribute must be false.
Example:
Response. Cookies ("Uto") ("UtorName") = UtorName
Response. Cookies ("Uto") ("UtorPwd") = UtorPwd
Response. Cookies ("Uto"). Domain = "utoper.com"
Response. Cookies ("Uto"). Secure = False
4, IE for. cn short domain support has a major BUG, no way to write Cookies, Someone tested: http://blog.csdn.net/xssh913913/archive/2007/08/04/1725882.aspx solution:
For example, for h5.cn domain names, all subdomain names in h5.cn write Cookies to the h5.cn domain no matter which subdomain name receives the information. Do not set the domain name when writing, that is, these two statements are not required.
Response. Cookies ("User"). Domain = "h5.cn"
Response. Cookies ("User"). Secure = False
In this way, Cookies can be called by any other subdomain name.
Related Article

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.