Re: session bug or feature
| From: | Christian Calloway | Date: | Fri, 08 Aug 2003 11:01:00 +0000 |
| Subject: | Re: session bug or feature | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-158870@lists.php.net to get a copy of this message | ||
Yeah I figured as much. That sucks that they would both reference the same
location in memory even with globals on. Thanks alot for your help, ill
figure out a hack around the hack.
Christian Calloway
"Kirk Johnson" <kjohnson@zootweb.com> wrote in message
news:B11731D518B5D61183C700A0C98BE0D9025872BC@chef...
> Under 4.3.2, and register_globals on, $foo and $_SESSION["foo"] both
contain
> a reference that points to the same memory location. So, assigning to
either
> one effectively causes the same assignment in the other.
>
> If you can't turn register_globals off, consider making a copy of
$_SESSION
> at the top of the script, then use that copy at the end of the script to
> restore any session values you need. You could also rename the global
> variables, e.g., "$foo" -> "$g_foo".
>
> I don't see an easy way out if you can't turn off register_globals, you
are
> going to have to do some work.
>
> Kirk
>
>
> > register_global is currently on. The problem is, I am hacking
> > into someone
> > else's (awful awful) code, and if I turned off
> > register_globals, the whole
> > application would go kaput. I am not even using the old
> > session_x functions,
> > just the new associative session array $_SESSION.
> >
> >
> >
> > "Curt Zirzow" <curt@zirzow.dyndns.org> wrote in message
> > news:20030807171325.GZ21938@bagend.shire...
> > > * Thus wrote Christian Calloway (callowaylc@yahoo.com):
> > > > Hey Everyone,
> > > >
> > > > I am running Apache 2.047 with PHP (as module) 4.3.2. I ran into
> > something
> > > > interesting and I wanted to know if it was a bug, or
> > actually supposed
> > to be
> > > > that way. Given the following lines of code:
> > > >
> > > > <?php
> > > >
> > > > session_start();
> > > >
> > > > // lets say this equals "bar" and it was set on a previous page
> > > > $_SESSION["foo"];
> > > >
> > > > $foo = "rab";
> > > >
> > > >
> > > > echo $_SESSION["foo"];
> > > >
> > > > ?>
> > >
> > >
> > > >
> > > > The problem is, when I set the global variable
> > $foo="rab", when I echo
> > the
> > > > session variable $_SESSION["foo"], it outputs "rab"
> > instead of "bar"?!