Reputation: 17
I tried the setHtpOnly(true) option but it doesn't seem to be working as it isn't a method in Cookie. I did see a few solutions using path but I'm not sure about that either.
This is my code.
Cookie cookie = new Cookie (name, entity);
cookie.setPath("/");
httpServletResponse.addCookie(cookie);
What can I do to set the httpOnly flag as true for the above code?
Upvotes: 0
Views: 973
Reputation: 11
What version of Java are you using? Are you seeing a specific error on compilation? This method seems to exist in Java EE since at least 6 and Servlet 3.1:
https://docs.oracle.com/javaee/6/api/javax/servlet/http/Cookie.html#setHttpOnly(boolean)
Upvotes: 1