httpOnly Session Cookie + Servlet 3.0 (e.g. Glassfish v3)

后端 未结 2 1046
半阙折子戏
半阙折子戏 2020-12-15 06:06

By default, Glassfish v3 doesn\'t set the httpOnly flag on session cookies (when created as usual with request.getSession()).

I know, there is a method

相关标签:
2条回答
  • 2020-12-15 06:54

    This is supported via a Servlet 3.0 web.xml (see web-common_3_0.xsd):

    <web-app>
      <session-config>
        <cookie-config>
          <!--             
            Specifies whether any session tracking cookies created 
            by this web application will be marked as HttpOnly
          -->
          <http-only>true</http-only>
        </cookie-config>
      </session-config>
    </web-app>
    
    0 讨论(0)
  • 2020-12-15 06:58

    You can also add <secure>true</secure> to boost the security.

    <session-config>
        <cookie-config>
            <http-only>true</http-only> 
            <secure>true</secure>
        </cookie-config>
    </session-config>
    
    0 讨论(0)
提交回复
热议问题