Variable Variable named sessions
Posted: Mon May 01, 2006 5:12 pm
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; (ive also tried ($_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. Can you not assign variable variable names for sessions? or any suggestions as to why this may not work
$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; (ive also tried ($_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. Can you not assign variable variable names for sessions? or any suggestions as to why this may not work