I have found this solution on Sof link
but i had to change it from two causes:
- there is no .getFacesContext()
function - i don’t have a specific cookie file
(see line
ourcookiename=yourcookievalue)
my code looks like this:
FacesContext facesContext = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
response.addHeader("Set-Cookie", "; HTTPOnly");
original code
FacesContext facesContext = FacesContext.getCurrentInstance().getFacesContext();
HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
response.addHeader("Set-Cookie", "yourcookiename=yourcookievalue; HTTPOnly");
please correct me if I’m wrong. Thank You in advance
In jsf 2.0 you can do this:
In this way, you don’t need to do the cast to HttpServletResponse. For more documentation about JSF, check MyFaces Documentation Index.