Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Session variables can be fooled (login)?

IN PHP: Is there a way for the user to fake a session variable?

Is it secure to trust in the value of a session variable for a login system?

like image 552
The Disintegrator Avatar asked Mar 15 '10 07:03

The Disintegrator


2 Answers

The session data is stored on the server. Only the session id is transferred forth and back between the client and the server. Unless a server-side script messes up (or there is a bug) the client cannot change the session data directly. But you have to ensure that only the "correct" client knows the session id, as it ties this particular client to a particular session. E.g. (since you mentioned a login) use session_regenerate_id() whenever a login (attempt) is performed to prevent session fixation

like image 152
VolkerK Avatar answered Oct 11 '22 13:10

VolkerK


Sessions are stored on your server, either in a file or in memory. The user only holds a cookie that defines the path (usually a hash of some form) to the session data on your server. Theoretically you could change the cookie to someone else's hash, but that is very, very improbable, unless you store them as files and don't delete them after they expire, in which case the probability of someone exploiting an old session would increase.

like image 23
animuson Avatar answered Oct 11 '22 14:10

animuson