misterx
06-04-2003, 11:20 PM
I'm having a really hard time figuring out how to use sessions to verify that a user is logged in from script to script. The script I have so far authenticates off a MySQL table I set up to verify that the name and pass entered are correct. That works fine.
Once the user gets authenticated I want to start a session, store their username in it, and pass it on to the next script. At the next script I want to check for the session and, if one does not exist, send them back to the login page.
Here's what I have so far. This is the code that gets executed after they type in the right user and pass info:
session_start();
session_register('authenticated');
$authenticated = $user;
$id = strip_tags(SID);
mysql_close($link);
header("Location: menu.php?".$id."");
exit;
Is that right? When I run this is doesn't pass anything in the URL after the 'menu.php?' so something isn't happening. Thanks in advance for the advice.
Once the user gets authenticated I want to start a session, store their username in it, and pass it on to the next script. At the next script I want to check for the session and, if one does not exist, send them back to the login page.
Here's what I have so far. This is the code that gets executed after they type in the right user and pass info:
session_start();
session_register('authenticated');
$authenticated = $user;
$id = strip_tags(SID);
mysql_close($link);
header("Location: menu.php?".$id."");
exit;
Is that right? When I run this is doesn't pass anything in the URL after the 'menu.php?' so something isn't happening. Thanks in advance for the advice.