SameSite = Lax可以远程工作,但不能在本地工作

问题描述 投票:0回答:1

[我看到使用SameSite=Lax在iframe内设置cookie时无法解释某些行为。

我有两台Web服务器,一台在your.example.com上,另一台在my.example.com中。your.example.com在iframe中加载my.example.com,其中my.example.com设置Cookie。这在实际的远程Web服务器上可以正常工作,并且cookie被设置为没有任何问题。

在我的本地环境中,我在localhost中加载一个,然后在iframe中加载my.localhost。当my.localhost返回Cookie时,我在Chrome联网标签中看到以下错误:The set-cookie had the "SameSite=Lax" attribute but came from a cross-origin response.

如果我在其自己的选项卡上加载my.localhost地址,则cookie会正确设置,但是当我返回localhost时,除了前面的错误消息外,我还会看到以下错误:This cookie had the "SameSite=Lax" attribute and the request was made on a different site. This does not include navigation requests initiated by other sites.

我正在使用Chrome版本80.0.3987.162(正式版)(64位)。有人可以解释这种行为以及如何使其在本地工作吗?

web-services cookies http-headers webserver samesite
1个回答
0
投票

我认为,如果将所有内容下移一个级别,您都会得到想要的行为。我的意思是,将dev.localhost或类似的子域视为您的顶级域。设置dev.localhost域中的cookie,您应该看到my.dev.locahostyour.dev.localhost被视为同一站点。换句话说,应该允许您的SameSite=Lax cookie。

注意:我需要返回并再次仔细检查一次,但是我有理由确信,当我测试类似的设置时,这种方法是可行的!因此,请自己尝试并验证。

© www.soinside.com 2019 - 2024. All rights reserved.