Skip to content

Instantly share code, notes, and snippets.

@abdulhadad
Created January 24, 2019 07:43
Show Gist options
  • Select an option

  • Save abdulhadad/69117643c902f9063a03cfdc4e79a4df to your computer and use it in GitHub Desktop.

Select an option

Save abdulhadad/69117643c902f9063a03cfdc4e79a4df to your computer and use it in GitHub Desktop.
Java HttpOnly Headers

HttpOnly Session

Kebutuhan

  • servlet 3+
  • konfigurasi web.xml
...
<session-config>
 <cookie-config>
  <http-only>true</http-only>
 </cookie-config>
</session-config>
  • atau untuk servlet 2.5 ke bawah
String sessionid = request.getSession().getId();
// be careful overwriting: JSESSIONID may have been set with other flags
response.setHeader("SET-COOKIE", "JSESSIONID=" + sessionid + "; HttpOnly");

Servlet 3 Web Server

  • Jboss EAP 6+
  • Jboss AS/Wildfly 6+
  • Tomcat 7+

Referensi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment