【发布时间】:2016-03-12 02:13:12
【问题描述】:
我正在尝试在 Liferay 中添加一个非 http only cookie。这是我在动作课上的尝试
Cookie cookie = new Cookie("testName", "testValue");
cookie.setMaxAge(60 * 60);
cookie.setPath("/");
cookie.setVersion(0);
cookie.setHttpOnly(false);
cookie.setSecure(false);
CookieKeys.addCookie(PortalUtil.getHttpServletRequest(request), PortalUtil.getHttpServletResponse(response), cookie, false);
cookie 已保存,我可以在浏览器的资源视图中看到它,但它只是 http,所以我无法使用 javascript 读取它。知道如何使它成为非 http 的吗?
编辑:
如果我只使用response.addProperty(cookie);,结果是一样的。
这是响应头
Set-Cookie: testName=testValue; Expires=Mon, 07-Dec-2015 15:15:27 GMT; Path=/; HttpOnly
【问题讨论】:
标签: javascript java tomcat cookies liferay