Java / Servlet Interview Questions
How to protect session cookies in Servlet?
For Java EE 6 (Servlet 3.0) the setHttpOnly and setSecure methods can be used to protect HTTP Cookies.
For older Java versions, there are no API available to directly set the HttpOnly and Secure flags. The workaround is creating a custom SET-COOKIE header.
String sessionId = request.gerSession().getId(); Response.setHeader("SET-COOKIE", "JSESSIONID=" + sessionId + "; HttpOnly; Secure");
More Related questions...