如何在同一域上为iframe设置Cookie [英] How to set a cookie for iframe on the same domain

查看:814
本文介绍了如何在同一域上为iframe设置Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在按照官方文档的示例1 http://etherpad.org/doc/v1.2.7/

I'm trying to make integration of etherpad-lite in the CMS Plone, following Example 1 of the official documentation http://etherpad.org/doc/v1.2.7/

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

除cookie之外,其他所有功能都运行良好。阅读文档的最佳实践似乎使etherpad-lite在特定路径下的同一域中。这是我使用/ pad /路径完成的操作。

Everythings goes well except for the cookie. Reading documentation the best pratice seems to make etherpad-lite in the same domain under a specific path. This is what I have done using /pad/ path.

如果没有创建会话,则创建克隆端,然后创建一个cookie,然后添加一个cookie

Plone side if no session has been created, I created on, I add a cookie and then I'm doing a redirect to the same page to be sure the cookie is in the browser.

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

As a results my cookie is added to the request of the main page but not ob the iframe request.

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

Here is the google chrome console network tab for the main page and the iframe:

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

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

The code corresponding to the setCookie is at https://github.com/toutpt/collective.etherpad/blob/master/collective/etherpad/archetypes.py#L100

推荐答案

对于后代,这是答案来自 @ AskoSoukka 在上面的评论中被识别并接受:

For posterity, here's the answer from @AskoSoukka identified and "accepted" in the comments above:


存储在您的浏览器中的实际cookie是什么样的?可能需要在setCookie kwargs中显式指定path = /才能使其在整个域中正常工作。

How does the actual cookie stored in you browser look like? Probably, you need to explicitly specify path="/" in setCookie kwargs to make it work for the whole domain.

这篇关于如何在同一域上为iframe设置Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆