【问题标题】:ASPXAUTH cookie duplicatedASPXAUTH cookie 重复
【发布时间】: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


    【解决方案1】:

    在 webconfig 中添加 slipExpiration 属性解决了这个问题

          <authentication mode="Forms" >
        <forms cookieless="UseCookies" name=".ASPXAUTH"  slidingExpiration="false" />
    

    【讨论】:

      猜你喜欢
      • 2015-04-08
      • 1970-01-01
      • 2010-12-26
      • 2010-09-30
      • 2018-12-08
      • 2013-05-01
      • 2012-04-29
      • 2012-06-03
      • 1970-01-01
      相关资源
      最近更新 更多