. 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 }