Session ID
A session ID, also known as a session identifier or session token, is a unique alphanumeric string generated by a web server to identify and track a user's interaction with a web application across multiple stateless HTTP requests.[1] It enables the maintenance of user-specific state, such as authentication status, shopping cart contents, or preferences, despite the inherent statelessness of the HTTP protocol.[2] Typically, the session ID is created upon the user's initial access or login and is stored server-side in a session object or database, while a client-side reference—often in the form of an HTTP cookie—is sent back to the user's browser.[1] The session ID is transmitted in subsequent requests via mechanisms like theCookie header, allowing the server to associate incoming traffic with the correct user session and apply appropriate access controls.[2] For security, session IDs must be generated using a cryptographically secure pseudorandom number generator (CSPRNG) with at least 64 bits of entropy—ideally 128 bits or more—to resist prediction or brute-force attacks, and they should be renewed after authentication or privilege changes.[1] Common vulnerabilities include session fixation, where an attacker forces a known ID on a victim, and hijacking via interception of the ID, underscoring the need for transmission over HTTPS with Secure and HttpOnly cookie flags to prevent exposure.[1] Sessions typically include idle timeouts (e.g., 2–30 minutes of inactivity) and absolute expiration (e.g., 4–8 hours) to limit exposure duration.[1]
Beyond web applications, session IDs appear in other protocols, such as the Session Initiation Protocol (SIP) for multimedia communications, where they provide end-to-end identification across devices and intermediaries.[3] In versions of Transport Layer Security (TLS) up to 1.2, session IDs identify resumable session states to optimize handshakes. In TLS 1.3 and later, session resumption uses session tickets instead.[4][5] However, the web context remains the most prevalent use, integral to modern frameworks like Django and PHP, which automate session handling through default cookie-based IDs.