【发布时间】:2018-10-24 11:28:57
【问题描述】:
我正在使用 FormsAuthentication.FormsCookieName 开发一个 WebApplication。我在 WebConfig 中有这个:
<httpCookies requireSSL="true" />
<authentication mode="Forms">
<forms cookieless="UseCookies"
name=".ASPXAUTH1" />
</authentication>
在代码中:
var httpCookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket))
{
HttpOnly = true,
Domain = "." +host, // Ex- host = google.com (without www because we use subdomains)
Secure = false
};
httpCookie.Expires = remember ? DateTime.Now.Add(FormsAuthentication.Timeout) : DateTime.Now.AddMinutes(1);
当我登录到网络应用程序时,一切看起来都很好:
带有红色箭头的域 = .google.com
几秒钟后,第二个 cookie 出现了不同的域 = www.google.com 和过期日期
我没有使用 RedirectToLoging 页面方法。
【问题讨论】:
标签: c# asp.net-mvc cookies session-cookies