The __Host- Cookie Prefix Narrows Session Cookie Scope
A session cookie can carry a strong random identifier and still have an unnecessarily broad scope. The Domain attribute can make a cookie available across subdomains, while a path-specific cookie can coexist with another cookie of the same name. Those details matter when several applications share a registrable domain but do not share the same security boundary.
The __Host- cookie-name prefix gives supporting user agents a compact rule set for a stricter cookie. A cookie whose name begins with __Host- must be set from a secure origin with Secure, must use Path=/, and must omit Domain. A user agent that implements the prefix rejects a prefixed cookie that violates those constraints.
The prefix does not turn a cookie into a complete session-security mechanism. It narrows where the cookie can be established and scoped. Authentication, session rotation, CSRF defenses, XSS controls, expiration, and server-side session handling remain separate concerns.
The prefix makes scope constraints machine-checkable
A conventional session cookie can express the desired attributes:
Set-Cookie: session=opaque-value; Secure; HttpOnly; Path=/The server intends a secure, host-only cookie because Domain is absent. The name itself, however, does not encode that intent.
With __Host-, the browser can enforce a specific combination:
Set-Cookie: __Host-session=opaque-value; Secure; HttpOnly; Path=/For a supporting user agent, these variants are invalid:
Set-Cookie: __Host-session=opaque-value; HttpOnly; Path=/
Set-Cookie: __Host-session=opaque-value; Secure
Set-Cookie: __Host-session=opaque-value; Secure; Path=/; Domain=example.comThe first lacks Secure. The second lacks the required root path. The third adds Domain, which is forbidden for this prefix.
That enforcement moves part of the cookie contract from application convention into user-agent processing.
Omitting Domain creates host-only scope
A cookie without Domain is host-only. If app.example.com sets it, the cookie is returned to that host rather than being scoped to sibling hosts through Domain=example.com.
app.example.com
|
| Set-Cookie: __Host-session=...; Secure; Path=/
v
host-only cookie
api.example.com no shared Domain scope
admin.example.com no shared Domain scopeThis distinction is useful when sibling subdomains have different operators, deployment stacks, or compromise exposure. A broadly scoped domain cookie increases the number of hosts that participate in its security boundary.
The prefix does not isolate ports. HTTP cookie scoping is not a port-based boundary. Services on different ports of the same host must not treat __Host- as port isolation.
Path=/ removes path-specific variants for the prefixed name
Cookie paths affect when a cookie is sent, but Path is not an authorization mechanism. The __Host- rules require Path=/, so the prefixed cookie applies across the host rather than being created with a narrower path.
That requirement also prevents a valid __Host- cookie from being established under a competing path such as /admin:
Set-Cookie: __Host-session=other-value; Secure; Path=/adminA supporting browser rejects that cookie because the path is not /.
The result is a simpler invariant for the prefixed name: its accepted scope is host-wide, not a collection of path-specific variants created under the same prefix contract.
__Secure- has a different boundary
The related __Secure- prefix requires a secure origin and the Secure attribute, but it does not impose the __Host- restrictions on Domain and Path.
This can be valid:
Set-Cookie: __Secure-session=opaque-value; Secure; Domain=example.com; Path=/That cookie may intentionally cover subdomains according to normal cookie domain rules. The choice between the prefixes therefore reflects scope requirements, not a ranking where one name is universally correct.
Use of a domain-wide cookie may be necessary for an architecture that deliberately shares state across hosts. In that case, __Host- is incompatible with the intended scope.
HttpOnly and SameSite remain independent attributes
__Host- does not imply HttpOnly. If a session identifier does not need script access, HttpOnly remains a separate attribute that prevents access through interfaces such as Document.cookie.
Likewise, __Host- does not select a SameSite policy. A server still chooses the cross-site sending behavior appropriate to the application:
Set-Cookie: __Host-session=opaque-value; Secure; HttpOnly; Path=/; SameSite=LaxSameSite, HttpOnly, and the prefix address different boundaries:
__Host- -> secure origin + host-only + Path=/
HttpOnly -> blocks script access through cookie APIs
SameSite -> constrains cross-site cookie sendingCombining them can be appropriate, but their effects should not be collapsed into a single claim about a cookie being secure.
Prefix enforcement depends on user-agent support
The extra constraints exist only in user agents that implement cookie prefixes. A client without prefix support can treat the name as an ordinary cookie name.
That compatibility boundary matters for applications with non-browser clients, embedded stacks, legacy software, or custom HTTP implementations. The server must not assume that the prefix proves every client enforced the rules.
Server-side policy should still emit the intended attributes consistently and validate session state independently. The prefix is defense in depth at the user-agent boundary, not evidence about the integrity of every HTTP client.
The prefix does not repair session design
A host-scoped cookie can still carry a predictable token, remain valid too long, survive a privilege change without rotation, or map to server-side state with weak revocation controls. None of those properties are fixed by the cookie name.
A robust session design can pair a __Host- cookie with controls such as:
opaque high-entropy session identifier
server-side expiration and revocation
rotation after authentication or privilege changes
Secure and HttpOnly where applicable
an explicit SameSite policy
CSRF protection suited to the request model
XSS prevention and output handlingThe prefix contributes one narrow guarantee in supporting browsers: an accepted __Host- cookie was set under the prefix’s transport and scope constraints.
Host scope is a useful default for isolated applications
Applications often need a session for one host, not every sibling beneath a parent domain. In that layout, a host-only cookie keeps the session boundary aligned with the application endpoint.
The __Host- prefix makes that intent visible in the cookie name and enforceable by compatible browsers. Its value is not stronger cryptography or a new authentication protocol. It is a stricter cookie namespace whose accepted attributes rule out domain sharing and path-specific scope.
That smaller boundary reduces accidental coupling between sibling applications while leaving the rest of session security explicit.
References
- MDN, Set-Cookie header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie
- MDN, Secure cookie configuration: https://developer.mozilla.org/en-US/docs/Web/Security/Practical_implementation_guides/Cookies