首页 > 解决方案 > 当链接目标为“_blank”时,Internet Explorer 11 丢失 iframe 嵌入式网站的 cookie - 相同的域,不同的子域

问题描述

https://subdomain-b.example.com当使用iframeon嵌入https://subdomain-a.example.com然后单击iframe在新选项卡/窗口中打开的 cookie 中的链接时,cookie 会丢失。

我不确定它是否与它有关,但一切都是严格的https

https://subdomain-a.example.com上的代码:

<iframe src="subdomain-b.example.com/index.php"></iframe>

https://subdomain-b.example.com/index.php上的代码:重要的是链接在 _blank 中打开

<?php
setcookie("TestCookie", "someValue");
?>
<a href="showcookie.php" target="_blank">link</a>

https://subdomain-b.example.com/showcookie.php上的代码:

<?php
print_r($_COOKIE);

https://subdomain-b.example.com/showcookie.php上的响应为空。

这适用于 Firefox、Chrome 和 Edge。

这一定与https://subdomain-a.example.com处理 iframe 内容的方式有关,它在某些实例上有效,而在其他实例上则无效。

标签: phpcookiesiframeinternet-explorer-11session-cookies

解决方案


推荐阅读