PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
itsmani1
Forum Regular
Posts: 791 Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:
Post
by itsmani1 » Mon May 09, 2005 7:51 am
Code: Select all
while($Row = mysql_fetch_object($Res))
{
$adminID = $Row -> adminID;
$HTTP_SESSION_VARS['adminID'] = $adminID;
$firstName = $Row -> firstName;
$HTTP_SESSION_VARS['firstName'] = $firstName;
$lastName = $Row -> lastName;
$HTTP_SESSION_VARS['lastName'] = $lastName;
$canAddProduct = $Row -> canAddProduct;
$HTTP_SESSION_VARS['canAddProduct'] = $canAddProduct;
}
see the above coad here in this coad i am registerign session vars. new i want to get the values of these session vars. how i will do that?
anjanesh
DevNet Resident
Posts: 1679 Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India
Post
by anjanesh » Mon May 09, 2005 9:31 am
Normally $_SESSION works like this - in my scripts :
$_SESSION['somevariable'] = $somevariable;
echo $_SESSION['somevariable']
Skara
Forum Regular
Posts: 703 Joined: Sat Mar 12, 2005 7:13 pm
Location: US
Post
by Skara » Mon May 09, 2005 5:23 pm
Yeah, $HTTP_SESSION_VARS is the old way of accessing them. Use $_SESSION now.
Also, you might as well shorten each line to this:
Code: Select all
$_SESSION['adminID'] = $Row->adminID;
*shrugs*
$_SESSION acts just like any other variable in this sense:
Code: Select all
echo $miscvar;
// ~ or ~
echo $_SESSION['whatever'];
// ~ or ~
echo $_GET['something_else'];