how to set httponly and session cookie for java web application

后端 未结 3 1544
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-14 10:30

I am working on an XSS (cross site scripting) issue. My application runs on an Oracle Weblogic portal. We use Servlet version 2.5.

I have added the below 3 lines o

3条回答
  •  旧巷少年郎
    2020-12-14 11:20

    Depending on the specifics of your web container, modifying container-managed session cookies within an app can cause the app server to toss the existing session and create a new one. I've observed this on Tomcat but it may be similar for Weblogic.

    If you're using Servlets 3.0, you can actually instruct the app server to ensure that all session cookies are HttpOnly and Secure with the following fragments:

    
      
        true
        true
      
    
    

    This is a better approach than manually hacking on the cookies with a filter.

    FYI: I've also written a Java library that injects a number of security related response headers in Servlet based apps.

提交回复
热议问题