. Net cookie cross-origin request specifies the request domain name,. netcookie

Source: Internet
Author: User

. Net cookie cross-origin request specifies the request domain name,. netcookie

1 HttpCookie cookie = new HttpCookie ("OrderApiCookie"); // you can specify the name of the Cookie. httpOnly = true; // if it is true, script files are not allowed to access 3 cookies. domain = ".taobao.com"; // note that the domain must be set to a vertex with a top-level Domain name. Define the domain name that can access cookies. 4 // DateTime dt = DateTime. now; 5 // TimeSpan ts = new TimeSpan (0, 1, 1, 0, 0); // The expiration time is 1 minute 6 // cookie. expires = dt. add (ts); // set the expiration time. If no time is set, 7 cookies will be destroyed when the browser is closed. value = ". net "; // assign 8 Response to the cookie. appendCookie (cookie); // return to the browser
Cookie. Domain is the Domain name that can be accessed. If .taobao.com is set here, all websites other than * .taobao.com cannot be accessed.
When cookie. HttpOnly = true, the foreground cannot obtain the cookie value.
1         function getCookie(cookieName) {2             var arr, reg = new RegExp("(^| )" + cookieName + "=([^;]*)(;|$)");3             if (arr = document.cookie.match(reg))4                 alert(unescape(arr[2]));5             else6                 alert("null");7         }

 

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.