Page 1 of 1

using arrays in sessions variables

Posted: Fri Nov 07, 2003 2:50 pm
by iso
I am having a hard time accessing data that is stored in an array in a session variable. I have a book that shows how to do this, but in the book they have global variables set to on, which I don't and would rather not have it.

By looking at the session object it can be seen that all the values are being stored properly so...

This is what I am doing at the moment, so obviously this is what does not work:

[php_man]
//store the variables in a local array var
foreach ($HTTP_POST_VARS as $varName=>$value)
{
$form[$varName] = trim(clean($value,50));//trim(clean($_POST["userName"],50));
}
$_SESSION["FORM_VARS"] = $form;


//this is the part that never prints the variable that I refer to
print "UserLevel";
print $_SESSION[$FORM_VARS["userLevel"]];
[/php_man]

I would really appreciate it if someone could look this over, because I have spent way to loing trying to figure it out

Posted: Fri Nov 07, 2003 2:52 pm
by d3ad1ysp0rk
whats it print out?

Posted: Fri Nov 07, 2003 3:14 pm
by McGruff
Syntax:

Code: Select all

<?php
 print $_SESSION[$FORM_VARS]["userLevel"];
?>

Posted: Fri Nov 07, 2003 3:29 pm
by iso
thanks for the help that works actually I still had to remove the $ from the FROM_VARS and quote it, but all is good now