ASP.NET MVC cookie不能保存?

为什么这个cookie没有保存在我的global.asax的Session_Start方法中?

//new anon user: var authCookie = new HttpCookie("user-id", string.Format("{0}-{1}", regiserAccountResponse.UserName, regiserAccountResponse.Key)) { Expires = DateTime.MaxValue, Domain = "domain.com", Secure = true, HttpOnly = true }; //create the new users cookie - there's no need to call RegisterNewUserSession as this is done in the same call HttpContext.Current.Response.SetCookie(authCookie); 

如果要将cookie限制为网站的特定部分,则只需指定域。 如果cookie位于正确的范围内,则cookie将仅包含在请求中。

通过将域设置为“domain.com”,您说该cookie只能用于“domain.com”,因此您不会从localhost(或来自domain.com以外的任何其他域)检测到它。 。

您还会注意到,如果您尝试从您自己的域以外的域向浏览器发送cookie,浏览器将对其进行bin。