Prevent the cookie being stolen
Set HTTP only:
There are a couple of ways to ensure that cookies are sent securely and are not accessed by unintended parties or scripts: the
There are a couple of ways to ensure that cookies are sent securely and are not accessed by unintended parties or scripts: the
Secure
attribute and the HttpOnly
attribute.Set-Cookie: id=a3fWa; Expires=Wed, 21 Oct 2021 07:28:00 GMT; Secure; HttpOnly
Set security cookie flag:
web.xml
Servlet 3.0 (Java EE 6) introduced a standard way to configure secure attribute for the session cookie, this can be done by applying the following configuration in web.xml
<session-config>
<cookie-config>
<secure>`true`</secure>
</cookie-config>
</session-config>