嗯,我正在使用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);当我登录到web应用程序时,一切看起来都很好:

带有红色箭头的域= .google.com
几秒钟后,第二个cookie出现,具有不同的域= www.google.com和过期日期

我没有使用RedirectToLoging页面方法。
发布于 2018-05-15 05:18:22
已解决在webconfig中添加slidingExpiration属性的问题
<authentication mode="Forms" >
<forms cookieless="UseCookies" name=".ASPXAUTH" slidingExpiration="false" />https://stackoverflow.com/questions/50336496
复制相似问题