【问题标题】:"SameSite=none" does not work with iframe“SameSite=none”不适用于 iframe
【发布时间】:2020-06-29 18:35:38
【问题描述】:

升级到 Chrome 版本 80.0.3987.132 后,cookie 不会发送到 iframe 请求。在网络选项卡(Chrome 开发工具)上,我没有看到我的请求的 cookie。

打开“显示过滤掉的请求 cookie”选项后,我看到我的 cookie 标记为 “由于用户偏好,未发送此 cookie。”

cookie 集的标头:

set-cookie: token=jf23HaUI91Bd8L1chHq; expires=Wed, 18-Mar-2020 16:01:59 GMT; Max-Age=1799; path=/; SameSite=None; secure; domain=.example-domain.com; HttpOnly

当我在同一个域上打开 iframe 时,一切正常,但如果它是通过 http 或 https 的第三方域,cookie 将不起作用。

有没有人遇到过或知道如何解决?

【问题讨论】:

  • 这是通过 https 吗?通过http,我认为这行不通。您的标头中有安全标志,需要安全连接
  • 有类似的问题:https + samesite=none;secure + iframe。 cookie 没有通过。你找到解决方案了吗@mikolay-bet

标签: google-chrome cookies samesite


【解决方案1】:

我认为您应该确保对于这些 cookie,SameSite 标志始终设置为“无”。如果它最初设置为 Lax,然后您尝试将其设为 None,它可能无法正常工作。

此外,您应确保 SameSite=None cookie 的 Secure 标志始终设置为 true。

【讨论】:

    【解决方案2】:

    它适用于我,通过 PHP 设置 cookie; 这是 php 的 HACK

    session_set_cookie_params(3600*24, '/;SameSite=None', $_SERVER['HTTP_HOST'], true);

    (安全 = true 很重要)

    【讨论】:

      【解决方案3】:

      如果托管在 IIS 中,您可以在 web.config 中添加以下配置,以避免通过浏览器添加 SameSite=Lex

      <sessionState mode="InProc" **cookieless="UseCookies" cookieSameSite="None"** timeout="20"/>
      

      【讨论】:

        【解决方案4】:

        chrome://settings/content/cookies上取消选择阻止第三方cookie

        【讨论】:

        • 这不是解决方案,您不能让所有用户都禁用第三方 cookie 拦截!
        猜你喜欢
        • 2020-05-21
        • 1970-01-01
        • 2020-05-28
        • 2020-12-19
        • 2021-03-03
        • 1970-01-01
        • 2020-09-01
        • 2011-03-30
        • 2011-10-15
        相关资源
        最近更新 更多