Table of Contents
Session hijacking happens when someone takes over an existing signed-in session. After you sign in, a website usually gives your browser a session cookie or token. The service uses that token to recognize later requests. If someone gets a valid token, they may be able to act as you until the service revokes it or it expires.

How sessions are exposed
- Compromised devices or browsers: Malware or a malicious browser extension can expose sessions even when the website uses HTTPS.
- Weak web application controls: Predictable identifiers, failure to replace a pre-login session at sign-in, or exposure of tokens in URLs or logs can leave accounts vulnerable.
- Unsafe handling of cookies: Unencrypted connections can expose tokens in transit. A cross-site scripting flaw can also let an unwanted script act within a signed-in page.
What to do if you suspect a hijacked session

Watch for unfamiliar devices in account settings, changes to your recovery details, and messages or purchases you did not make. An unexpected location by itself is inconclusive because mobile networks and VPNs can change how a location is reported.
- From a trusted device, go directly to the service’s security settings and choose Sign out of all devices or revoke active sessions. Contact support if you cannot do this.
- Change the password, review recovery settings and connected apps, and enable multi-factor authentication. A password change alone may leave some sessions active.
- Check account activity and notify the appropriate support or security team. If you suspect malware, avoid signing in again on the affected device until you have dealt with it.
How websites can prevent session hijacking
- Serve the entire authenticated session over HTTPS, use HSTS where appropriate, and configure session cookies with
Secure,HttpOnly, and aSameSitesetting suited to the application. - Use the framework’s session manager, rotate session IDs at sign-in and privilege changes, enforce idle and absolute timeouts, and invalidate sessions server-side at logout.
- Keep raw tokens out of URLs and logs. Monitor for unexpected account activity, provide a way to revoke sessions, and require fresh authentication for sensitive actions. MFA at login protects future sign-ins, while session revocation addresses an already exposed token.
For implementation guidance, see the OWASP Session Management Cheat Sheet.
Reader Comments 0
Sign in with email or Google to join the discussion.