Page 1 of 1

Accessing session arrays

Posted: Mon Mar 03, 2003 3:05 pm
by lostboy
Hi All,

Question: when accessing a session variable array, how can I write it?

is the correcnt syntax

Code: Select all

for($x=0;$x<$_SESSION&#1111;'numbooths'];$x++;)&#123;
	print "Booth #:".$_SESSION&#1111;'booths']&#1111;$x];
&#125;
or

Code: Select all

for($x=0;$x<$_SESSION&#1111;'numbooths'];$x++;)&#123;
               print "Booth #:".$booths&#1111;$x];
&#125;
TIA

Posted: Mon Mar 03, 2003 3:11 pm
by pootergeist
if you set the session variable with

$_SESSION['numbooths'] = 3;

you would access it as you have done - obviously declaring session_start() somewhere prior.

Posted: Mon Mar 03, 2003 3:25 pm
by lostboy
pootergeist wrote: you would access it as you have done
Yes...but which syntax is correct? the first ex or the second?

TIA

Posted: Mon Mar 03, 2003 3:31 pm
by puckeye
If you have register_globals set to off then only the first exemple will work otherwise either are valid.

Posted: Mon Mar 03, 2003 3:36 pm
by lostboy
thanks that cleared it up :P