iframe 无法种 cookie,无法读取当前域名下的 cookie

原创
2021/05/27 20:50
阅读数 1.3K

网页  http://hd.abc.com/ccms/preview

<script>
console.log('iframe 1', document.cookie)
document.cookie = "_csrf_token=DQjXlN8f-LDXEHi0k_Z4YTOh6zi7KtxHP_XU";
document.cookie = "_csrf=AF5QKt-PuClNFBwN-9cUsQCI";
console.log('iframe 2', document.cookie)
</script>

网页 iframe-test.html

<iframe src="https://hd.abc.com/ccms/preview/" style="width: 500px; height: 500px"></iframe>

http://localhost:5000/iframe-test.html
file:///Users/pauli/iframe-test.html.html
http://local.test.com:5000/iframe-test.html
上面三个网页,都不能种 cookie 到当前 iframe 自己的网页

只有下面的地址,可以成功(为什么呢,也是不同的域名,难道是默认的 SameSite=Lax):
http://local.abc.com:5000/iframe-test.html

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部