Re: Session: where is my mistake?

From: Date: Thu, 31 Aug 2000 13:10:10 +0000
Subject: Re: Session: where is my mistake?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-14575@lists.php.net to get a copy of this message
You need to call session_start() in each PHP script before you call session_register() or session_destroy(). "Radu Filip" <radu@tuiasi.ro> wrote in message news:Pine.LNX.4.21.0008311627350.13784-100000@eureka.cs.tuiasi.ro... > > Hi! I try to write some kind o wizard in PHP. This wizard will get some > information from the user, in several steps and then, it will call a > proceed page. Unfortunatelly, I have some problems with sessions. > > Here is a sample of what I trying to do: > > [radu@gamma test]$ cat step1.php > <? > session_start(); > echo "<form method=post action=\"step2.php\">"; > echo "Name: "; > echo "<input type=text name=person_name><br>"; > echo "<input type=submit name=submit value=next>"; > echo "</form>"; > ?> > > [radu@gamma test]$ cat step2.php > <? > session_register("person_name"); > echo "<form method=post action=\"step3.php\">"; > echo "Address: "; > echo "<input type=text name=person_address><br>"; > echo "<input type=submit name=submit value=next>"; > echo "</form>"; > ?> > > [radu@gamma test]$ cat step3.php > <? > session_register("person_address"); > echo "<form method=post action=\"step4.php\">"; > echo "<input type=submit name=submit value=finish>"; > echo "</form>"; > ?> > > <? > echo "You entered the following information:<br>"; > echo "Name: $person_name<br>"; > echo "Address: $person_address<br>"; > session_destroy(); > echo "<a href=\"step1.php\">Back to step 1</a>"; > ?> > > > Unfortunatelly, when I reach step 4 I get this result: > > You entered the following information: > Name: > Address: > Warning: Trying to destroy uninitialized session in > /home/staff/radu/public/web/html/test/step4.php on line 7 > Back to step 1 > > which is not what I need. So, where is my mistake regarding to sessions > management? > > Thx, > Radu > > P.S. My PHP4 is compiled with the following options: > > ./configure --with-apxs --enable-force-cgi-redirect --enable-trans-sid > --enable-register-globals > > I use a RH Linux 6.2 distribution and Apache 1.3.12 (shiped with > distribution). PHP version is 4.0.2 > > -- > Radu Filip > Network Administrator @CCTI | tuiasi.ro > radu@tuiasi.ro ccti@tuiasi.ro > http://socrate.tuiasi.ro/ > http://www.ccti.tuiasi.ro/ > > > -- > 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 (#14575) next »