【问题标题】:How to set a cookie for iframe on the same domain如何在同一域上为 iframe 设置 cookie
【发布时间】:2013-02-12 16:14:55
【问题描述】:

我正在尝试在 CMS Plone 中集成 etherpad-lite,遵循官方文档 http://etherpad.org/doc/v1.2.7/ 的示例 1

Portal places the cookie "sessionID" with the given value on the client and creates an iframe including the pad.

一切都很好,除了饼干。阅读文档的最佳实践似乎使 etherpad-lite 在特定路径下的同一域中。这就是我使用 /pad/ 路径所做的。

如果没有创建会话,我创建了 Plone 端,我添加了一个 cookie,然后我正在重定向到同一页面以确保 cookie 在浏览器中。

因此,我的 cookie 被添加到主页的请求中,而不是 iframe 请求中。

这是主页和 iframe 的 google chrome 控制台网络标签:

http://toutpt.makina-corpus.org/en/images/cookie-in-iframe/

setCookie对应的代码在https://github.com/toutpt/collective.etherpad/blob/master/collective/etherpad/archetypes.py#L100

【问题讨论】:

  • 这就是我指定 iframe 在同一个域中的原因。我认为这是一个不同的用例。
  • 浏览器中存储的实际 cookie 是什么样的?可能,您需要在 setCookie kwargs 中明确指定 path="/" 以使其适用于整个域。
  • @AskoSoukka 这似乎是一个很好的答案。我已经添加了路径选项,现在它已添加到 iframe 请求中。
  • 请注意,您的问题与 Plone 无关。 :-)

标签: cookies session-cookies etherpad


【解决方案1】:

为了后代,这里是来自@AskoSoukkathe answer 在上面的 cmets 中被识别和“接受”:

存储在浏览器中的实际 cookie 是什么样的?可能,您需要在 setCookie kwargs 中明确指定 path="/" 以使其适用于整个域。

【讨论】:

    猜你喜欢
    • 2011-01-08
    • 2011-06-09
    • 2012-04-21
    • 2020-03-04
    • 2011-09-28
    • 2011-10-09
    相关资源
    最近更新 更多