Page 1 of 1
name sessions from post variables
Posted: Sun Apr 18, 2004 10:32 pm
by snpo123
i am trying to create and name sessions from post variables and i am not quite sure how to do it. here is what i have so far:
session_start();
$_SESSION['{$_POST['name']}'];
$_SESSION['{$_POST['email']}'];
i know this is completly wrong, and I was wondering if someone could help me do it right
thanks
Posted: Sun Apr 18, 2004 10:34 pm
by tim
i believe you simply just want:
$_SESSION["user"] = $_POST["username"];
Posted: Sun Apr 18, 2004 10:36 pm
by snpo123
duh, i am such an idiot...lol
thnx man
Posted: Sun Apr 18, 2004 10:40 pm
by snpo123
wait... how would I print the value of that session on another page?
Posted: Sun Apr 18, 2004 11:24 pm
by John Cartwright
you would need
session_start(); at on line1
then:
echo $_SESSION['sessionname'];
Posted: Mon Apr 19, 2004 5:16 pm
by tim
Phenom is most correct.
any page you wish to access session variables must have a session_start();
But - I would assign it to a variable, ie:
$user = $_SESSION['username'];
echo $user;
Makes it so you dont have to keep typing $_SESSION cause if your like me, i always forget to make the underline and $SESSION, oh well! lol
