We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在我理解中浏览器相当于一个 Cookie仓库,当你发出请求时,都会从自己这个仓库中去搜寻目标域名的cookie,如果满足发送的条件,则会自动的将 Cookie 放到请求的Header中。
第一方 Cookie:我们的域名是 ybf.com,访问我们的服务时,会自动设置 ybf.com 域名下的 Cookie。
ybf.com
第三方 Cookie:我们的域名是 ybf.com,我的网页访问时,使用 acc.com 这个域下的资源, acc.com 这个域会设置一个属于 acc.com 的 Cookie。
acc.com
Cookie 的SameSite属性用来限制第三方 Cookie,从而减少安全风险。
SameSite
此表格来自SameSite小识
如果你的 Chrome 的设置为限制第三方 Cookie ,就是将 SameSite 安全级提高到 Strict,限制一切第三方 Cookie。所以测试时关闭 Chrome 的限制第三方 Cookie 。
我们在ybf.com中加载了acc.com的资源,看到了第三方 Cookie 的警告。
这里不指定 SameSite 的值,看到 Cookie 工作为 None 的特性。
可以看到有警告:需要将 Secure 设置为 True。
这就要求我们需要将 http 升级为 https。
我们先给acc.com设置上 Cookie imge=imge(属性中包含 sameSite: 'lax' ) 然后关闭网页。
imge=imge
sameSite: 'lax'
然后我们在ybf.com中添加一个a标签 <a href="http://acc.com:4000">跳转去acc页面</a>,
<a href="http://acc.com:4000">跳转去acc页面</a>
和一个img标签 <img src="http://acc.com:4000/imge">。
<img src="http://acc.com:4000/imge">
我们访问ybf.com然后我们点击查看 Nerwork查看img标签的网络请求。
可以看到加载imge时不会加载 Cookie。然后我们点击a标签进行跳转。
跳转时添加上了 Cookie。
SameSite cookies
Cookie 的 SameSite 属性
SameSite小识
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Cookie-SameSite
在我理解中浏览器相当于一个 Cookie仓库,当你发出请求时,都会从自己这个仓库中去搜寻目标域名的cookie,如果满足发送的条件,则会自动的将 Cookie 放到请求的Header中。
什么是第三方 Cookie
第一方 Cookie:我们的域名是
ybf.com
,访问我们的服务时,会自动设置ybf.com
域名下的 Cookie。第三方 Cookie:我们的域名是
ybf.com
,我的网页访问时,使用acc.com
这个域下的资源,acc.com
这个域会设置一个属于acc.com
的 Cookie。SameSite属性介绍
Cookie 的
SameSite
属性用来限制第三方 Cookie,从而减少安全风险。此表格来自SameSite小识
测试
如果你的 Chrome 的设置为限制第三方 Cookie ,就是将 SameSite 安全级提高到 Strict,限制一切第三方 Cookie。所以测试时关闭 Chrome 的限制第三方 Cookie 。
我们在
ybf.com
中加载了acc.com
的资源,看到了第三方 Cookie 的警告。这里不指定 SameSite 的值,看到 Cookie 工作为 None 的特性。
设置为 None
可以看到有警告:需要将 Secure 设置为 True。
这就要求我们需要将 http 升级为 https。
设置为 Lax
我们先给
acc.com
设置上 Cookieimge=imge
(属性中包含sameSite: 'lax'
) 然后关闭网页。然后我们在
ybf.com
中添加一个a标签<a href="http://acc.com:4000">跳转去acc页面</a>
,和一个img标签
<img src="http://acc.com:4000/imge">
。我们访问
ybf.com
然后我们点击查看 Nerwork查看img标签的网络请求。可以看到加载imge时不会加载 Cookie。然后我们点击a标签进行跳转。
跳转时添加上了 Cookie。
参考
SameSite cookies
Cookie 的 SameSite 属性
SameSite小识
The text was updated successfully, but these errors were encountered: