HttpOnly

A cookie attribute that stops scripts running in the page from reading the cookie, while the browser still sends it on requests.

Without it, any script injected into the page can steal the session.

In more detail

It limits the damage of cross-site scripting: injected code cannot simply copy the session cookie and send it elsewhere. Set it on every session cookie.

Example

In the browser: Session cookies should be HttpOnly so an XSS attack cannot steal them with document.cookie. The browser still sends them with requests.

Related terms

Taught in

References