Page 1 of 1

direct calls to session variables an array.

Posted: Fri Jan 31, 2003 4:39 pm
by EricS
Ive tried the following code

Code: Select all

$HTTP_SESSION_VARSї'check'] = array(1 => 1);
and it does not give an error but it also doesn't take the array. Now if I do the following

Code: Select all

$check = array(1 => 1);
then it works just fine. Im using PHP 4.0.6. Is there a bug in this version or am I not supposed to be using the global variable like I am. FYI I am using session_start and session_register, I just didn't include that in the code here.


Also if I can't use the code in the first example, is it better to initialize a session variable locally before I use it

Code: Select all

$check = $HTTP_SESSION_VARї'check'];
$check = 1;
vs just using it
$check = 1;
Which is the proper way to use it?

Thanks

Posted: Fri Jan 31, 2003 8:47 pm
by redcircle
If you are using a version of PHP later than 4.1 then it is easier to initialize session variables with

Code: Select all

$_SESSIONї'check'] = array(1 => 1);

Posted: Sat Feb 01, 2003 11:33 am
by twigletmac
I've found with PHP 4.0.6 that trying to use $HTTP_SESSION_VARS seems to just not work. Although you may have more luck if you don't try and mix session_register() and $HTTP_SESSION_VARS - they definitely don't play nicely together.

Mac