Skip to content
BENIBIX Learn

Session Hijacking

Development🔐 SecurityAttacks

Also known as Session Hijack, Cookie Hijacking, Session Theft

Stealing someone's login so you can act as them. No password is needed.

Think of it like

Think of it like a wristband at a fair. Whoever has it gets in as you.

Example

A script on a forum page reads Lucy's session cookie and sends it away. The attacker pastes it in and is logged in as Lucy.

Why it matters

A stolen session skips the password and even the second step. The site sees a normal user.

Definition

Session hijacking is stealing someone's logged-in session to act as them. After you log in, the site gives your browser a session ID, often in a cookie. Whoever holds that ID looks like you to the site. Attackers steal it through XSS, unsafe Wi-Fi or a leaked link. Safe cookie settings, HTTPS and short sessions make it much harder.

Example code

http
Set-Cookie: session=7f3a9c; HttpOnly; Secure; SameSite=Lax
HttpOnly hides the cookie from page scripts, and Secure sends it only over HTTPS.
The right panel: the login itself was stolen, so no password is needed.

Common mistake

Leaving the session cookie open to scripts. The HttpOnly flag stops page scripts from reading it.

Key takeaways

  1. 1
    The ID is the key. Whoever holds it is you.
  2. 2
    Many ways to steal. XSS, open Wi-Fi and leaked links.
  3. 3
    Lock the cookie. HttpOnly, Secure and short lives.