Quote:
Originally Posted by ChrisTheSoul
Hi Alex - cheers for the response.
Erm, I'm a little confused...
So a session variable runs for the course of the session presumably, i.e. until the user closes their browser window?
I understand the principle of the username and password in a table that I can then match with the login details that are posted, but what about the session column, what does that do?
The random number thing has thrown me a little too.
|
Yes the session will be there until the browser is closed (or if session_destroy() is called)
The purpose of the session column is that the random session is unique to the user for that period of time.
Hackers can change their session to make them seem as someone else.
example:
The script checks to see what username is in the 'user' session, if it finds a match it will show that users private messages.
so tom comes along with a session user that will look like this:
$_SESSION['user'] = "tom";
Now if Tom where to edit this with some easy to find tools, he could change it to:
$_SESSION['user'] = "Frank";
Giving him access to all Frank's messages.
The session 'seskey' (almost) stops this.
example 2.
the same as before except the script checks to the user session
and the seskey session. So Tom is:
$_SESSION['user'] = "tom";
$_SESSION['seskey'] = "gifj87er8934uerfjdi" //random string
the script will find the username and match it and will find that the seskey matches the session column, granting him access to his mail.
Now if Tom tried to change his session again he could change his user session to frank fine, but it could take him days to generate the random session to access franks mail.
As Toms session is:
$_SESSION['seskey'] = "gifj87er8934uerfjdi"
and Franks could be:
$_SESSION['seskey'] = "cdjijf8574jfd84899"
or anything! and Tom would have to go through every single combination until he had the right match.
You cannot stop him from doing that (at least not a way I know) but you can make him have to generate ridiculous amounts to get access.
If you follow, I will go on else I will try and explain further.
P.S. I spent ages on that ha! Should be a newsletter tut!