PDA

View Full Version : Question about sessions


ArcadEd
03-23-2006, 08:56 PM
I'm trying to wrap my head around using a session. I only have one variable that I need to follow the user after they logon, and I just can't seem to grasp it.


ON a successful login I have this. $uname is a variable defined earlier in the code.


session_start();
session_register("globname");
$globname = $uname;


Then on other pages I'm trying to pull the information from that variable using.


$NewVar = $_SESSION['globname'];


What am I missing? Thanks, I've been reading so much on global variables in general, I think I have all this new information in my head that is just getting all crisscrossed :).

I appreciate the help.

djm0219
03-23-2006, 09:09 PM
$uname is a variable defined earlier in the code.


session_start();
$_SESSION["uname"] = $uname;


Then on other pages ...


$NewVar = $_SESSION["uname"];

ArcadEd
03-23-2006, 09:36 PM
Thanks Dave, but still no luck. Can you think of any reason why?

Code I have now.

first page


session_start();
$_SESSION["uname"] = $uname;


Call on second page

$User = $_SESSION["uname"] ;


I have a simple echo on the second page to show me if $User is assigned anything, and it's not.

Thanks.

bustamelon
03-23-2006, 09:40 PM
The session_start() needs to appear on every page where you need the SESSION vars.

ArcadEd
03-23-2006, 09:43 PM
Ahh Ha.

THANKS!

Works great now. I don't know how I missed that in everything I read :). Thanks again, both of you.

bustamelon
03-23-2006, 10:59 PM
You bet.
It's those vital little tidbits that always seem to get left out of the docs, or buried somewhere.