RE: [PHP] session data missing

From: Date: Fri, 11 Jul 2003 09:35:01 +0000
Subject: RE: [PHP] session data missing
Groups: php.general 
Request: Send a blank email to php-general+get-154844@lists.php.net to get a copy of this message
> -----Original Message----- > From: Kevin Stone [mailto:kevin@helpelf.com] > Sent: 09 July 2003 20:30 > > ----- Original Message ----- > From: "ulf sundin" <majikthse@spray.se> > To: <php-general@lists.php.net> > Sent: Wednesday, July 09, 2003 1:00 PM > Subject: Re: [PHP] session data missing > > > > ok, so now the variable names are registred and stored in > the file. But > > without values. > > check this: > > > > --firstpage.php---- > > session_start() > > session_register('foo'); > > $HTTP_SESSION_VARS['foo'] = 'bar'; > > echo $HTTP_SESSION_VARS['foo']; //outputs bar; > > > > transport by a href to: > > ----secondpage.php---- > > session_start(); > > echo $HTTP_SESSION_VARS['foo']; //outputs nothing > > > > --- > > checking the contents of the file called /tmp/sess_{session_id}: > > !foo| > (snip) > > > Make a choice here.. > > => session_register('foo'); > => $HTTP_SESSION_VARS['foo'] = 'bar'; > > Use either the session_register() function or the session > global array. Not > both. Not true -- $HTTP_SESSION_VARS is *not* like $_SESSION, and its values are *not* auto-registered. In fact, I still have my copy of the 4.0.6 manual around, and it specifically gives this as an example: > Example 1. Registering a variable > > <?php > session_register("count"); > $HTTP_SESSION_VARS["count"]++; > ?> However, it's a little unclear on whether this should still work regardless of the register_globals setting, as it also gives this as an example: > Example 2. Registering a variable with register_globals enabled > > <?php > session_register("count"); > $count++; > ?> I guess I'd have to go away and try it to be sure of what behaviour occurs for each setting of register_globals -- but there seems little point given that using $_SESSION has been much the best option for several versions now! Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@lmu.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#154844) next »