Re: SESSIONS! - please help

From: Date: Thu, 06 Sep 2001 17:52:19 +0000
Subject: Re: SESSIONS! - please help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-66251@lists.php.net to get a copy of this message
this allways buggers people up session_register("count"); $count = array(); should be $count = array(); session_register("count"); you have to set the var first before registering it. you should also check if the var is allready registerd ($HTTP_SESSION_VARS[]) if so, dont re-register it, this can cause session to segfault apache every so often. www.mediawaveonline.com/exmaples/session.txt this is my session file I use, take a look at what I mean. also your using php4 so try foreach() its alot nicer, just looks better. foreach($count as $key => $value) vs while (list($key, $value) = each ($count)) -- Chris Lee lee@mediawaveonline.com "Christian Haines" <cmh@cobweb.com.au> wrote in message news:B7BDE0A1.B01A%cmh@cobweb.com.au... > hi all, > > PHP-4.03pl > LINUX 7.0 > > i am still having problems with sessions. the following does nothing but > should appear to do something! it is just a simple experiment to test that > sessions work. session_test.php calls session_proc.php to perform one of > three functions. > > i would really appreciate any help as this is driving me nuts. i have also > tested this on other systems to no avail. > > many thanks in advance, > christian > > > ------------- session_test.php ------------------------------------------ > <html> > > <body> > <? > if(is_array($count)) > { > reset ($count); > while (list($key, $value) = each ($count)) { > echo "Key: $key; Value: $value > Count:".count($value)."<br>\n"; > > if(is_array($value)) > { > reset ($value); > while (list($key2, $value2) = each ($value)) { > echo "---> Key: $key2; Value: $value2 <br>\n"; > } > } > } > } > > print "<br>&nbsp;<br>".count($count)." > ---".session_is_registered("count"); > > ?> > <form name=test method=post action=session_proc.php> > <input name=increment type=submit value=increment><input name=reset > type=submit value=reset><input name=decrement type=submit value=decrement> > </form> > > </body> > </html> > > ------------- session_proc.php ------------------------------------------ > <? > session_start(); > > session_register("count"); > $count = array(); > > if(isset($increment)) > { > $count[0] = 9; > $count[1] = 11; > $count[2] = 12; > } > > if(isset($reset)) > { > unset($count); > } > > if(isset($decrement)) > { > $count[0] = 4; > $count[1] = 6; > $count[2] = 1; > } > > header("location: session_test.php"); > exit; > ?> >

« previous php.general (#66251) next »