What is Session Hijacking?
An attack where an attacker steals or predicts a valid session token to gain unauthorized access to a user's authenticated session. Once hijacked, the attacker can act as the legitimate user without knowing their password.
Also known as: Cookie Hijacking, Session Theft
When you log into a website, you get a session token—a digital hall pass that proves you're authenticated. Session hijacking steals that pass, letting attackers impersonate you.
How Sessions Work
- You authenticate with username/password
- Server creates session, issues token (usually cookie)
- Browser sends token with every request
- Server validates token, grants access
- No re-authentication needed until session expires
Attack Methods
Network Sniffing (Sidejacking)
- Intercept tokens over unencrypted WiFi
- Tools like Firesheep made this trivial
- HTTPS largely solved this
Cross-Site Scripting (XSS)
- Inject JavaScript to steal cookies
document.cookiesends tokens to attacker- Most common modern method
Session Fixation
- Attacker sets session ID before victim logs in
- Victim authenticates with attacker's ID
- Attacker now shares the authenticated session
Malware
- Keyloggers capture session data
- Browser extensions with too many permissions
- Token-stealing malware
Protection Mechanisms
For Websites
- HTTPS everywhere (encrypt tokens in transit)
- HttpOnly cookies (prevent JavaScript access)
- Secure flag (only send over HTTPS)
- SameSite cookies (prevent CSRF)
- Short session timeouts
- Session binding (IP, user agent)
For Users
- Use HTTPS only
- Log out when done (destroy session)
- Don't use public WiFi without VPN
- Clear sessions after using public computers
- Watch for session warnings
Detecting Hijacking
Signs Your Session Was Hijacked
- Unexpected logouts
- Actions you didn't take
- Location/device alerts
- Security notifications
Account Recovery
- Change password immediately
- Revoke all sessions
- Enable 2FA if not already
- Check for unauthorized changes
- Review connected applications
Related Terms
Cookie
A small piece of data stored in your web browser by websites you visit. While cookies enable useful features like staying logged in, they're also used extensively for tracking your browsing activity across the web for advertising and analytics purposes.
Two-Factor Authentication
A security method requiring two different types of identification to access an account: something you know (password) plus something you have (phone, hardware key) or something you are (biometric). This significantly reduces the risk of unauthorized access even if your password is compromised.
Have more questions?
Use our guided flow to get the right next privacy step for Session Hijacking.
Open Guided Flow