PDA

View Full Version : PHP Session??


sir pannels
10-21-2002, 11:31 AM
hey there!
ok I need some help here,
ive been workin on a massive member area.. and it all works on a variable from the url like when u login it goes to a page like..www.whatever.com/blah.php?id=2928 it then finds that id from a db and displays the info for that member, the problem is that if someone just types that url in they can get into that account without needin a password, so i researched a bit and it seems i need a session variable... ok cool so any idea show I do this?
any info would be great.
thanks
P

Galdo
10-21-2002, 02:46 PM
Have a look here for an article on sessions:

http://www.webmasterbase.com/article.php?pid=0&aid=319

And it might be worthwile to have a look in the PHP manual here:

http://www.php.net/manual/en/ref.session.php

But in basic terms what you want to do is start a session using:


session_start();


Then assign a variable to the session using:


session_register('ID');
$ID = "$ID";


Then check they have an ID, then check that the ID is the one which was stored in the database at the start of the session:


IF(!isset($HTTP_SESSION_VARS["ID"])) {
session_destroy();
Header("Location: errorpage.php");
exit;
}

Spookster
10-21-2002, 03:57 PM
and here's another:

http://hotwired.lycos.com/webmonkey/00/05/index2a.html?tw=programming

sir pannels
10-21-2002, 06:26 PM
...thanks alot it was really usefulll links you guys posted me
cheers :)
P