HttpOnly
noun
say it: “AYCH-tee-tee-PEE OHN-lee” /ˌeɪtʃˌtiˌtiˈpi ˈoʊnli/
A cookie setting that hides the cookie from the page's JavaScript, while the browser still sends it to the server.
What does the HttpOnly cookie flag do?
HttpOnly is a flag on a cookie that keeps the page's own JavaScript from reading it. The browser still sends the cookie with every request, but a harmful script slipped into the page can't steal the session id inside it.
res.cookie("sid", sessionId, { httpOnly: true, secure: true, sameSite: "lax" });
// Set-Cookie: sid=...; HttpOnly; Secure; SameSite=Lax
In a sentence
- “Mark every session cookie HttpOnly, Secure and SameSite.”
- “Because the session cookie is HttpOnly, document.cookie doesn't show it.”
Level: Journeyman · More Web Development terms at this level
Updated