【发布时间】:2015-03-17 14:05:37
【问题描述】:
我需要向我的页面添加令牌以验证 iframe 中的应用程序。 问题是,当我将域设置为 cookie 时,它不会添加到页面中。我在检票口示例中创建 cookie:
WebResponse webResponse = (WebResponse) RequestCycle.get().getResponse();
Cookie cookie = new Cookie("MY_AUTH_TOKEN", "token");
cookie.setPath("/");
cookie.setDomain("domain_in_iframe.com");
webResponse.addCookie(cookie);
HTML:
<iframe src="http://domain_in_iframe.com/" style="width:100%; height:500px;">
</iframe>
当使用 setDomain 时,浏览器中不存在 cookie。不使用 serDomain 方法 cookie 存在,但显示为带有 localhost 域的 cookie。
即使在 webbrowser 中手动添加 cookie 也可以,但这段代码不行。任何想法为什么?
【问题讨论】:
标签: authentication cookies wicket