Second-level domain name Cookie Problem and Solution)

Source: Internet
Author: User

after using the second-level domain name in the blog garden, it is found that even if the user has logged on, the second-level domain name blog page shows that the user has not logged on (as shown in the form of a comment, you must enter a verification code, the favorites function cannot be used normally). After you log on again, you still need to log on to other second-level domain names. In the Code . isauthenticated is used to determine whether the current request is verified. In the past, it was normal to use the www.cnblogs.com domain name. It seems that the domain name is different. For form verification, the verification is carried out through the cookie and the request is executed. when isauthenticated, the client will request the corresponding cookie. The cookie name is in the web. as specified in config, for example, blog garden web. settings in config:

That is to say, the request is being executed. when isauthenticated, code like this will be executed, httpcookie cookie = request. cookies [". dottextcookie "]; we know that cookies are associated with domain names, and httpcookie has a domain attribute. The problem encountered in the blog garden is that the second-level domain name cannot access the cookie of the primary domain name.ProgramUsing formsauthentication. setauthcookie sets the cookie, and the login code is executed under the domain name www.cnblogs.com. The cookie domain name is set to www.cnblogs.com by default, and we cannot access this cookie under the second-level domain name, how can this problem be solved? Can the cookie domain be set to be valid for all second-level domain names? Search for it in Google, and finally found an articleArticle(Tips on using subdomain), you can set the domain associated with the cookie to ". domain. Ext", and set the blog garden to .cnblogs.com. In this way, after formsauthentication. setauthcookie, add this code to solve the problem:

Httpcookie cookie = request. Cookies [". dottextcookie"];
If (cookie! = NULL)
{
Cookie. Domain = ".cnblogs.com ";
Response. Cookies. Add (cookie );
}
Note:
1. If you still need to log on to the second-level domain name again, delete the cookie file in your computer. The path is in C: \ Documents and Settings \ User Name \ cookies and c: \ Documents and Settings \ User Name \ Local Settings \ Temporary Internet Files, the file format is: User Name @ www.cnblogs.com, and then log on again.
2. If you find other problems related to the second-level domain name, please contact me in time.
3. if you encounter a "runtime error" when visiting the blog, it is because the DLL file has just been updated. You can re-open IE in 1 or 2 minutes.
4. Now the second-level domain name is fully enabled.

This article is reproduced from Taipa studio: http://www.dezai.cn/article_show.asp? ArticleID = 19687

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.