Session Hijacking and Cookie Theft

What is Session Hijacking?

Session Hijacking, also known as session sidejacking, session hijacking, and sometimes cookie hijacking, is the exploitation of a valid computer session to gain unauthorized access to information or services in a computer system. In particular, it is used to refer to the theft of a magic cookie used to authenticate a user to a remote server.


Session Hijacking Techniques

There are several techniques that attackers use to exploit session hijacking vulnerabilities:


Preventing Session Hijacking

Preventing session hijacking involves using secure connections, regularly regenerating session IDs, and setting the HttpOnly flag for cookies. Secure connections (HTTPS) encrypt the data between the client and the server, making it harder for an attacker to steal the session cookie. Regularly regenerating session IDs makes it harder for an attacker to predict the session ID. Setting the HttpOnly flag for cookies prevents client-side scripts from accessing them, protecting them from theft.