Join our Newsletter — 33% off our NHI Course
Authentication, Authorisation & Trust

HTTP Cookies

← Back to Glossary
By NHI Mgmt Group Updated November 3, 2026 Domain: Authentication, Authorisation & Trust

HTTP cookies are small name value data stored by a browser and sent back to the same website with later HTTP requests. They let web applications keep state across requests, such as session identifiers, preferences, or consent flags, and can be scoped with attributes like domain, path, expiry, Secure, and HttpOnly.

How HTTP cookies work

Cookies are a browser-mediated state mechanism built on top of otherwise stateless HTTP. A server sets a cookie, the browser stores it, and later sends it back only when the request matches the cookie’s scope rules. That simple loop is what lets websites remember a login, a shopping cart, or a user preference across many separate requests.

The browser does not send every cookie everywhere. Scope attributes determine which requests are eligible, and those attributes are part of the security story as much as the data itself. Domain and path limit where a cookie is attached, expiry controls how long it survives, and flags such as Secure and HttpOnly change when and how the value can be exposed.

Cookie scope is what turns a convenience feature into an access-bearing object. If a cookie is too broadly scoped, more hosts or paths can receive it than intended, which increases the chance of leakage or misuse. If a session cookie is long lived or sent over an insecure channel, an attacker who learns the value may be able to replay it as the user.

The strongest protection usually comes from narrowing exposure at the transport, browser, and application layers together. Secure reduces cleartext transmission risk, HttpOnly limits exposure to script-based theft, and careful domain and path choices help keep a cookie tied to the smallest practical trust boundary. Used badly, cookies become a reusable bearer token rather than a controlled state handle.

Many real problems with cookies come from implementation mistakes rather than the concept itself. A site may assume that a cookie means the current browser session is trustworthy, when in fact the value may have been stolen, copied between devices, or reused after logout if server-side invalidation is weak. Cross-site request issues can also appear when state-bearing cookies are accepted without enough request context checks.

Another common failure is confusing persistence with security. Long expiry improves convenience, but it also lengthens the window in which a stolen cookie can be abused. Likewise, using cookies to hold sensitive or high-value state without strong validation can create a quiet persistence mechanism for session hijacking, preference tampering, or unauthorized state changes.

Where cookies fit in modern web application design

Cookies remain a core web primitive because they solve state continuity across a protocol that does not retain memory between requests. That makes them useful for authentication sessions, consent choices, and other browser-managed state, but they are not a safe place for arbitrary application data just because they are easy to set.

In practice, well-designed applications treat cookies as a transport for a limited identifier or state pointer, not as a trust decision by themselves. The server should still validate the user, the session, and the action. Where the cookie represents authentication state, the application should also assume that replay, theft, and cross-context reuse are the main dangers to design against, not just accidental deletion or expiry.

Risk and Threat Considerations

Cookies are attractive to attackers because they can function like reusable access tokens. If a session cookie is stolen through scripting abuse, insecure transport, malware, or device compromise, the attacker may not need the password at all. Broad scope, long lifetime, and weak invalidation all increase the value of a captured cookie.

Failure mechanism: The browser sends a valid cookie to the target site, so the server accepts the request as an already authenticated session even though the original holder is no longer in control.

Impact: Session hijacking, unauthorized account actions, and persistence after logout or password change can follow if the application does not revoke or rebind the session correctly.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP ASVS, NIST SP 800-53 Rev 5 and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP ASVSV7 — Session ManagementHTTP cookies commonly carry session state and session identifiers.
V3 — Web Frontend SecurityCookie attributes and browser exposure are part of frontend state handling.
Recommendation — Apply V7 to bind session cookies to robust lifecycle, fixation, and invalidation controls. Use V3 to minimise client-side exposure of sensitive cookie values.
NIST SP 800-53 Rev 5IA-5 — Authenticator ManagementCookies may carry bearer-like session state that must be controlled across its lifecycle.
SC-8 — Transmission Confidentiality and IntegritySecure cookies depend on protected transport when they are sent back to the server.
Recommendation — Manage cookie-backed session material with lifecycle, revocation, and renewal controls. Protect cookie transport with confidentiality and integrity controls on all relevant requests.
NIST CSF 2.0PR.AA-05 — Managed Access ControlCookies help enforce authenticated access, so their handling affects access control outcomes.
Recommendation — Enforce access decisions with tightly scoped, revocable cookie-based sessions.

Practitioner Guidance

Why practitioners should care: Cookie handling is one of the smallest implementation details that can have the largest trust impact. The design decision is not just whether a cookie exists, but whether it is scoped, protected, and invalidated in a way that matches the sensitivity of the state it carries.

What to watch for: Treat any cookie that represents authentication, authorization, or other sensitive session state as a security boundary object. That means reviewing its scope, lifetime, transport protections, and invalidation behaviour as part of normal application security work, not as a cosmetic browser setting.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on November 3, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org