using arrays in sessions variables

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

Post Reply
iso
Forum Newbie
Posts: 2
Joined: Fri Nov 07, 2003 2:50 pm

using arrays in sessions variables

Post 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
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

whats it print out?
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Syntax:

Code: Select all

<?php
 print $_SESSION[$FORM_VARS]["userLevel"];
?>
Last edited by McGruff on Wed Aug 10, 2005 11:10 am, edited 1 time in total.
iso
Forum Newbie
Posts: 2
Joined: Fri Nov 07, 2003 2:50 pm

Post 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
Post Reply