HTTP is inherently a stateless protocol. To preserve user state across multiple page navigations (e.g. keeping you logged into your email or shopping cart), web applications assign a unique Session Identifier (Session ID) upon authentication. Because the possession of this session identifier is legally equivalent to knowing the user's password, compromising session tokens allows attackers to execute Session Hijacking and Account Takeover (ATO).
In a Session Fixation attack, the adversary forces a known session identifier onto a victim before the victim logs in:
PHPSESSID=ATTACKER_ID_999.https://bank.com/?PHPSESSID=ATTACKER_ID_999.PHPSESSID=ATTACKER_ID_999 and are immediately logged in as the victim.Whenever a user logs in, logs out, or elevates privileges, the application must immediately destroy the old session and issue a brand new session identifier:
// In PHP: Destroy old session ID and issue a new random ID upon login
if (password_verify($password, $userHash)) {
session_regenerate_id(true); // true deletes the old session data file!
$_SESSION['user_id'] = $userId;
}
Spring2026!) against thousands of user accounts.Set-Cookie: session_id=e3b0c44298fc1c149afbf4c8996fb924;
Secure;
HttpOnly;
SameSite=Strict;
Path=/;
Max-Age=1800;
Broaden your defensive and offensive security knowledge across our curriculum:
Defeating password compromise and session takeover with hardware keys.
Setting HttpOnly, Secure, and SameSite attributes to lock down session cookies.
Implementing account lockout policies and distributed throttling.
How to fix session fixation and session replay vulnerabilities in web apps.