[opencms-dev] Unable To Set Cookies In Page Elements

Brett Sheeran brett.sheeran at gmail.com
Wed Feb 10 05:43:09 CET 2010


Hi,

I find that code for setting cookies inside a page element does not succeed.

Here is some simple code placed inside an element:
-----
     Cookie cookie = new Cookie ("ELEMENT_COOKIE", "value1");
     cookie.setMaxAge(31536000);//secs in a year
     cookie.setPath("/");
     response.addCookie(cookie);
-----
There are no errors, but *definitely* no cookies either. I checked
using both request.getCookies(); and the show cookies button in my
Safari browser.

However, the previous code *will* work if placed inside the template
JSP that calls the page element.

Furthermore, the Following code does not work in a page element either.
     CmsRequestUtil.setCookieValue(cms, "ELEMENT_COOKIE2", "value2");

Any suggestions?

Thank you.

Regards Brett Sheeran



More information about the opencms-dev mailing list