gpt4 book ai didi

javascript - 隔离 iframe session

转载 作者:行者123 更新时间:2023-11-30 12:12:53 27 4
gpt4 key购买 nike

我有 6 个 iframe,它们来自同一个域,但具有不同的 url 和子目录。他们都使用 html header “set-cookie”设置了一个名称相同但值不同的 cookie。我需要将它们的 cookie 分开,这样它们就不会相互干扰。

这是一个示例代码。谢谢

<html>
<head>
<style type="text/css">
body, table
{
margin: 0; padding: 0; height: 100%; width: 100%; overflow: hidden; scrolling=no; position:absolute;;
}
iframe
{
height: 100%; width: 100%;
}
</style>

</head>
<body>
<table>

<tbody>
<tr>
<td>
<iframe id="1" src="http://example.com/1"></iframe>
</td>
<td>
<iframe id="2" src="http://example.com/2"></iframe>
</td>
<td>
<iframe id="3" src="http://example.com/3"></iframe>
</td>
</tr>
<tr>
<td>
<iframe id="4" src="http://example.com/4"></iframe>
</td>
<td>
<iframe id="5" src="http://example.com/5"></iframe>
</td>
<td>
<iframe id="6" src=http://example.com/6></iframe
</td>
</tr>
</tbody>
</table>
</body>

Note that I don't have access to the server/domain.

最佳答案

Cookie 包括 a path attribute :

If the attribute-name case-insensitively matches the string "Path",the user agent MUST process the cookie-av as follows.

If the attribute-value is empty or if the first character of the
attribute-value is not %x2F ("/"):

Let cookie-path be the default-path.

Otherwise:

Let cookie-path be the attribute-value.

Append an attribute to the cookie-attribute-list with an attribute-name of Path and an attribute-value of cookie-path.

Cookie 是 only sent if the cookie path matches the URL path .

配置您的服务器,以便它为框架中的 6 个事物中的每一个提供不同的路径。

关于javascript - 隔离 iframe session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33276043/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com