RE: [PHP] array session variable problem (register_global=off)
| From: | Johnson, Kirk | Date: | Wed, 20 Feb 2002 23:55:59 +0000 |
| Subject: | RE: [PHP] array session variable problem (register_global=off) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-85640@lists.php.net to get a copy of this message | ||
Doh! I meant this:
$_SESSION['name']['first'] = 'First Name';
> -----Original Message-----
> From: Harry Yu [mailto:yuharry00@yahoo.com]
> Sent: Wednesday, February 20, 2002 4:52 PM
> To: php-general@lists.php.net
> Subject: RE: [PHP] array session variable problem
> (register_global=off)
>
>
> Thanks for your reply,
>
> I have no problem assigning variable. I just can't
> retrieve them. If I use $_SESSION[foo['bar']], I got
> this error in Apache log.
>
> [Wed Feb 20 16:44:50 2002] [error] PHP Parse error:
> parse error, expecting `']''.
>
> Any other idea?
>
> Thanks,
> Harry
>
> The code in the first file is correct if
> register_globals is on. Since it is
> off, remove the call to session_register() and just
> assign values directly
> to $_SESSION, e.g.,
>
> $_SESSION[name['first']] = 'First Name';
>
> Kirk
>
> > -----Original Message-----
> > From: Harry Yu [mailto:yuharry00@yahoo.com]
> > Sent: Wednesday, February 20, 2002 2:12 PM
> > To: php-general@lists.php.net
> > Subject: [PHP] array session variable problem
> (register_global=off)
> >
> >
> > Hi All,
> >
> > I have register_global = off and I have problem
> > retrieving array session variable. For example;
> >
> > Page1.php
> >
> > <?php
> >
> > $name = array();
> > session_register ("name");
> >
> > $name[first] = "First Name";
> > $name[last] = "Last Name";
> >
> > ?>
> >
> > Page2.php
> >
> > <?
> >
> > session_start();
> >
> > echo $_SESSION[name['first']];
> > echo $_SESSION[name][first];
> >
> > ?>
> >
> > None of these works. The session file does
> registered
> > the array and variables. I can retrieve the array
> > with the register_global on. Any ideas?
> >
> > Thanks,
> > Harry
hp
>