Home  >  Article  >  Web Front-end  >  How to implement second-level domain name or cross-domain sharing of cookies_javascript skills

How to implement second-level domain name or cross-domain sharing of cookies_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:02:061688browse


Notes:
1. When you have a Cookie group (or Cookie dictionary) and use the Domain attribute to specify the domain name, when you modify or add members of the group, you must Add the Resonse.Cookies(cookieName).Domain attribute after the operation.
2. If it is not necessary, please do not modify the Cookie group that has set the Domain. Directly use Response.Cookies("CookieText") = CookieValue to create a new Cookie. For each independent Response.Cookies("CookieText"), regardless of whether there is a dictionary, it is written once. If it needs to be written multiple times, use another 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. There is a major bug in IE's support for .cn short domain names. Cookies cannot be written. Someone tested it: http://blog.csdn.net/xssh913913/archive/2007/08/04/1725882.aspx Solution :
For example, in the domain name h5.cn, among all subdomain names of h5.cn, no matter which subdomain name the information is received from, it will be sent to the domain name h5.cn for writing Cookies. Do not set the domain name when writing, that is, this Two sentences are not required.
Response.Cookies("User").Domain = "h5.cn"
Response.Cookies("User").Secure =False
In this way, when calling Cookies in any other subdomain, it will work normally .
Statement:
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