Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't get session variable 1

Status
Not open for further replies.

LWolf

Programmer
Feb 3, 2008
77
US
This is my first time using session variables and I thought they are accessible throughout the site if they are set. I set my $_SESSION['user'] on my login page and but cannot read it once it gets to the next main page. The program is not throwing any errors.

Login_chk.php
Code:
$_SESSION['user']=$xmgr->fname . " " . $xmgr->lname; // Initializing Session
echo $_SESSION['user'];
if ($xmgr->position == "Manager") {header("location: manager.php");}
else {header("location: employee.php");}

The above echo statement prints the correct information. On the employee page there is nothing.
Code:
echo "<b>Hello:</b>" . $_SESSION['user'];

What is wrong here?
 
Have you called session_start() in the employee page before trying to access $_SESSION?



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
That fixed it. I did not know you needed that on each page. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top