Attack Types

What Is Session Hijacking?

An attack where an adversary takes over a valid user session by stealing or predicting the session identifier. Once the attacker has the session ID, they can impersonate the user and perform any action the user is authorized to do.

In Laravel Applications

Prevent session hijacking in Laravel by setting secure session options in config/session.php: "secure" => true (HTTPS only), "http_only" => true (no JavaScript access), "same_site" => "lax" (cross-site protection). Also regenerate session IDs after login with session()->regenerate().

Example

If http_only is false in your session config, an XSS vulnerability could steal the session cookie via document.cookie, allowing an attacker to impersonate the user.

Related Terms

Related Articles

Monitor Your Laravel Application's Security

StackShield continuously checks your Laravel application from the outside, catching security issues before attackers find them.

Start Free Trial