Page 1 of 1

retrieving $username from $_SESSION

Posted: Mon Jan 26, 2004 9:29 pm
by glennn3
I had started a site with a pretty uncomfortable username/password auth. script with which i also queried the database membership list, of course... the script became a bit too cumbersome and i swapped it out with a sessions auth. script like so:

Code: Select all

function cleanMemberSession($username, $password) {

$_SESSIONї"username"]=$username;
$_SESSIONї"password"]=$password;
$_SESSIONї"loggedIn"]=true;
}
now that i've gone and done this, the only problem i have is getting the $username variable into the query form without carrying it around all over the site posting and getting it in the url string (seems a bit redundant to me..., plus it'd be nuts to rewrite all the links with ?username=$username...)

i realize my inexperience is showing. i'm just hoping there's gotta be a way to translate the session that's registered into the username variable that's registered along with it when i need to in one script instead of totin' it around in all the urls...

am i asking the right question? making any sense?

i appreciate the help...

glenn

Posted: Mon Jan 26, 2004 9:49 pm
by ilovetoast
Just keep the session going for the duration of the user's visit (on every page). Then $_SESSION["username"] will always be accessible and you can print it when/where you need to, without having to put it on every link.

peace

Posted: Mon Jan 26, 2004 10:20 pm
by glennn3
very nice thank you. god i love this stuff.