My vulnerability scanner recommends that I implement the HttpOnly flag, also known as "secure cookies". I want to set the HttpOnly flag. How do I accomplish that?
- HttpOnly is an additional flag, not it's own cookie. It is included in the Set-Cookie HTTP response header.
- Using the HttpOnly flag helps mitigate the risks of client-side scripting / XSS attack vectors.
- It tells the browser that this particular cookie should only be accessed by the server, and anything else is strictly forbidden.
- This only works if the browser supports it, but nearly all modern browsers do. Do keep this in mind, though.
- It is not a "silver bullet", it just makes it harder to collect data that nobody should have other than the server.