Re: Need Help with $_SESSION.
| From: | Scott Fletcher | Date: | Wed, 03 Jul 2002 19:57:48 +0000 |
| Subject: | Re: Need Help with $_SESSION. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-105276@lists.php.net to get a copy of this message | ||
Still working on the script. Here what I found out so far. Why does the
example #1 work and example #2 doesn't?
Example #1
Page 1
$_SESSION[0] = "Zero";
$_SESSION[1] = "One";
Page 2
echo $_SESSION[0];
echo $_SESSION[1];
Example #2
Page 1
$array[0] = "Zero";
$array[1] = "One";
//This is either for an array or
//substitute array for odbc_fetch_into
for($x=0;$x<2;$x++) {
$_SESSION[$x] = $array[$x];
}
Page 2
echo $_SESSION[0];
echo $_SESSION[1];
"Scott Fletcher" <scott@abcoa.com> wrote in message
news:20020703190544.52521.qmail@pb1.pair.com...
> The demostration written by Kirk Johnson worked pretty well. So, it
should
> work with my demo script I posted earlier today. Alright! I'm going to
> have to debug it to find the problem. I'll post the final script once
> everything is ironed out. Hope to get it done today.
>
> Thanks,
> FletchSOD
>
> "Kirk Johnson" <kjohnson@zootweb.com> wrote in message
> news:01A4B59FD1EBD311838100A0C98BE0D9023C4953@chef...
> > > Now, I still can not understand why the 2nd page show the $_SESSION as
> > > blank. It is suppose to contain datas. The php.net stated
> > > that $_SESSION
> > > is global. Any comments?
> >
> > register_globals on
> > -------------------
> > Page 1
> > <?
> > session_start();
> > $foo = 'bar';
> > session_register('foo');
> > $foo = 'someNewValue';
> > ?>
> >
> > Page 2:
> > <?
> > session_start();
> > echo $foo;
> > $foo = 'aDifferentValue';
> > ?>
> >
> >
> > register_globals off
> > --------------------
> > Page 1:
> >
> > <?
> > session_start();
> > $_SESSION['foo'] = 'bar';
> > $_SESSION['foo'] = 'someNewValue';
> > ?>
> >
> > Page 2:
> > <?
> > session_start();
> > echo {$_SESSION['foo']}; // several syntaxes to do this
> > $_SESSION['foo'] = 'aDifferentValue';
> > ?>
> >
> > Kirk
>
>