PDA

View Full Version : PHP Sessions



Encrypted!
04-09-2006, 06:00 PM
Ok im making a login script, and i want to apply sessions so other pages can sense wether the user is logged in. I can build a login without sessions (pointless), but when i apply them, it doesnt work.

Here is my MySQL queries:



$username = $HTTP_POST_VARS['name'];
$password = md5($HTTP_POST_VARS['pass']);

$result = mysql_query("SELECT COUNT(*) AS numfound FROM members WHERE username='$username' AND password='$password'");

$result_ar = mysql_fetch_array($result);


By using the code above, can anyone tell me how to store the users username in a session and see if there username is stored in the session?

Ive used the session_start() and the session_register() but it doesnt intergrate with my login.

Thanks! Encrypted!

nets
04-09-2006, 10:12 PM
You'll probably find it will be easier to look for a tutorial on sessions and one on MySQL.

Jackboy
05-09-2006, 07:07 PM
Right... im a bit out of practice but i think it goes like this




$_SESSION['username'] = $username
$_SESSION['password'] = $password


However i am not POSSITIVE
I doubt its right lol.. Worth a try though ey ;P

Encrypted!
06-09-2006, 04:49 PM
Yeah ive tried that.
Thanks anyway, think ive figured it.

Want to hide these adverts? Register an account for free!