any reason this php doesnt make sense to you

BigTaf

Gawd
Joined
Aug 4, 2004
Messages
905
I need to be able to creat variable variable named sessions. So basically

$curdev = "device".$_SESSION['HTinfo']->numdevicesused;

ends up being "device1", "device2", etc. If i echo it, it displays the correct name

then I assign information to it with

$_SESSION[$curdev]->thing1=99;

so this should in theory create $_SESSION[device1]->thing1=99

however when I try and access it as such

echo ($_SESSION['device1']->thing1);

or

echo ($_SESSION["device1"]->thing1);

or

echo ($_SESSION[device1]->thing1);

I get nothing. Ive been using session variables throughout this project and all other variables work fine. I have initalized the object, and can access the object manually(that code is not shown). Can you not assign variable variable names for sessions?
 
when echoing just a variable, I do not use parenthasis...

echo $_SESSION['device1']->thing1;
 
yah it seems to work either way

I find the brackets make it easier for me
 
Did you try accessing it as an array?

echo $_SESSION[$curdev]['thing1'];
 
jrbryner said:
Did you try accessing it as an array?

echo $_SESSION[$curdev]['thing1'];

I defined it as an object in the first place. I dont see that working
 
Back
Top