Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to modify the $_SESSION variable?

Tags:

http

php

Is it possible for an malicious user to set the $_SESSION (in php) variable to any value he wants?

like image 538
Luke Avatar asked May 20 '11 08:05

Luke


People also ask

Can session variables be modified?

Session variables on the client are read-only. They cannot be modified. In order to change the value of a session variable, an Ajax Callback is required. Similarly, if a session variable changes on the server, it will not be updated on the client until an Ajax Callback is made from the client.

How do you modify session variable?

To update any value stored in the session variable, start the session by calling session_start() function and then simply overwrite the vakue to update session variable. We just updated the value of userid in the session variable from 1 to 1111.

Can a user modify a session?

Session information is stored on the server. That means the user can not change it.

Can I change session value in browser?

Double-click a cell in the Key or Value column to edit that key or value.


3 Answers

Highly depends on your code. Something very obvious: $_SESSION['username'] = $_REQUEST['username'].

like image 77
KingCrunch Avatar answered Oct 16 '22 11:10

KingCrunch


Yes, by using another user's session data, as shown here: http://phpsec.org/projects/guide/4.html

like image 26
Nightfirecat Avatar answered Oct 16 '22 11:10

Nightfirecat


It depends on how you set the sessions variable. An user can exploit the way you set them.

The most common attacks with sessions is session fixation : http://en.wikipedia.org/wiki/Session_fixation

like image 3
Brice Favre Avatar answered Oct 16 '22 10:10

Brice Favre