Setting Cookie Secure Flag – Java
Method #1
Create secure cookie by calling setSecure method, which allows cookie to be secure
Cookie newCookie = new Cookie("name","value"); newCookie.setSecure(true);
Method #2
Add the following lines to web.xml file of the project to make the cookie secure.
<session-config> <cookie-config> <secure>true</secure> </cookie-config> </session-config>
Leave a Reply
Want to join the discussion?Feel free to contribute!