direct calls to session variables an array.

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
EricS
Forum Contributor
Posts: 183
Joined: Thu Jul 11, 2002 12:02 am
Location: Atlanta, Ga

direct calls to session variables an array.

Post 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
User avatar
redcircle
Forum Commoner
Posts: 43
Joined: Fri Jan 31, 2003 8:47 pm
Location: michigan, usa

Post 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);
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

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