Session Cookie
A session cookie is a small, temporary data file that a website stores in a user's browser only for the duration of their visit. Unlike cookies that persist across visits, it is typically discarded when the browsing session ends, so it is often used to keep track of a user's activity in real time while they move through a site.
A session cookie is an HTTP cookie sent without a Max-Age or Expires attribute, causing the browser to treat it as non-persistent and delete it when the current session ends; note that the browser, not the server, defines when a session terminates, and behavior can vary by browser (for example, some restore prior sessions). In IAM contexts, a session cookie commonly carries or references a server-side session identifier used to maintain authenticated state after an initial authentication step, distinguishing it from persistent cookies and from token-based approaches. The cookie itself is a session-state transport mechanism and does not by itself perform authentication or authorization; its security depends on configuration such as Secure, HttpOnly, and SameSite attributes, which are out of scope for this base definition.
Why it matters
Session cookies are a foundational mechanism for maintaining authenticated state in web applications. After a user completes an initial authentication step, the application typically issues a session cookie that carries or references a server-side session identifier, allowing subsequent requests to be associated with the already-authenticated principal without re-prompting for credentials. This makes the session cookie a high-value target: whoever holds a valid session cookie can generally act as the authenticated user for the life of that session, which is why its handling and protection matter as much as the authentication event that preceded it.
Because a session cookie transports session state rather than performing authentication or authorization itself, its security depends heavily on configuration and on how the browser and server manage session lifetime. A subtle but important point for architects is that the browser, not the server, defines when a session ends, and behavior varies across browsers; some restore prior sessions on relaunch, which can extend the practical lifetime of a cookie the server intended to be short-lived. Misalignment between server-side session expectations and browser-side persistence can leave authenticated state available longer than intended.
Understanding session cookies also clarifies the design tradeoff between server-side session approaches and token-based approaches, a comparison teams routinely weigh when choosing how to maintain state after login. Neither is universally superior; the choice depends on deployment context, scalability needs, and how session invalidation, storage, and validation are handled.
Who it's relevant to
Inside Session Cookie
Common questions
Answers to the questions practitioners most commonly ask about Session Cookie.
