RE: [PHP] Updating a value in a session

From: Date: Thu, 12 Apr 2001 14:37:59 +0000
Subject: RE: [PHP] Updating a value in a session
Groups: php.general 
Request: Send a blank email to php-general+get-48326@lists.php.net to get a copy of this message
another good way is to use an associative array $session[] as your only session variable, that way you don't need to worry abopout session variables overwriting local or vice versa, so $value as a session variable becomes $session["value"] Tim Ward Senior Systems Engineer Please refer to the following disclaimer in respect of this message: http://www.stivesdirect.com/e-mail-disclaimer.html > -----Original Message----- > From: Plutarck [mailto:aemuli@spamclause-yahoo.com] > Sent: 12 April 2001 13:24 > To: php-general@lists.php.net > Subject: Re: [PHP] Updating a value in a session > > > What happens is when you use session_start(), all variables > in the session > become initialized to the values they have previously been given. > > So when you call session_start the second time, a variable > named $value is > created with the value it was given earlier. > > The problem is, it over-writes the variable $value which was > submitted in > the form. > > The way to get around this is to rename your form to > "form_value". Then > right after you register value in your session, insert this: > > $value = $form_value; > > It should work without error. > > > -- > Plutarck > Should be working on something... > ...but forgot what it was. > > > > ""Tobias Talltorp"" <tobias@talltorp.com> wrote in message > news:9b431b$fau$1@toye.p.sourceforge.net... > > On my first page I have a form that posts a value to page2 > where it gets > > registered in a session. Works like a charm... > > When I try to do this again, but send another value, the > session doesn´t > > update the new value. > > Why? > > > > PAGE 1 ---> > > <form action="page2.php" method="post"> > > > > <input type="text" name="value" size="30"> > > <input type="submit" name="submit"> > > > > </form> > > > > > > PAGE 2 ---> > > <? > > session_start(); > > session_register("value"); > > ?> > > > > Thanks, > > // Tobias > > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > > > > >

« previous php.general (#48326) next »