【问题标题】:Chrome Not Set Session's CookieChrome 未设置会话的 Cookie
【发布时间】:2020-11-27 21:05:26
【问题描述】:

我有一个 ASP.NET MVC 电子商务应用程序。我们的帮助台向我报告了一些 chrome 浏览器在我们的网站上存在问题。我发现了问题,但我无法解决问题。问题是某些 chrome 浏览器没有设置会话 cookie。会话没有 cookie,应用程序当然使用会话,因此应用程序在某些 chrome 浏览器上无法正常运行。您可以在下面看到我的会话设置。 我能做些什么?我没有解决问题。

//global.asax
protected void Session_Start(Object sender, EventArgs e)
{
    Session["init"] = 0;
    Session.Timeout = 10080;
}

//web.config 
<sessionState cookieName="MySessionId" cookieSameSite="None" timeout="1000" mode="Custom" 
   customProvider="MySessionStateStore">
  <providers>
    <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" 
          host="x.x.x.x" accessKey="" ssl="false" port="6379" />
  </providers>
</sessionState>

【问题讨论】:

标签: c# asp.net asp.net-mvc iis cookies


【解决方案1】:

我找到了解决方案。某些 chrome 版本是在没有 https 的情况下阻止同站点 cookie。 我在 web.config 中添加了“requireSsl”属性。

原因:https://www.chromestatus.com/feature/5633521622188032

解决方案:

<httpCookies sameSite="None" requireSSL="true"  />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-18
    • 1970-01-01
    • 2015-02-26
    • 2011-07-13
    • 1970-01-01
    • 1970-01-01
    • 2011-11-03
    • 2020-11-27
    相关资源
    最近更新 更多