__Host- prefix
A cookie name prefix that the browser only accepts if the cookie is Secure, has Path=/ and names no domain, so subdomains cannot overwrite it.
In more detail
Because the cookie is locked to the exact host that set it over HTTPS, a compromised or malicious subdomain cannot plant a fake session cookie on the main site. Browsers enforce the rules, so the server gets them for free by choosing the name.
Example
Set-Cookie: __Host-sess=tok_xyz; Path=/; Max-Age=3600; HttpOnly; Secure; SameSite=StrictRelated terms
- cookie — A small named value a server asks a browser to store and send back automatically on later matching requests.
- Set-Cookie — The response header a server uses to ask the browser to store a cookie, together with attributes that limit where it is sent.
Taught in
- Session Architecture: HTTP-Only Cookies vs Tokens — Production Full-Stack Engineering