Re: Re: change value of session variable?

From: Date: Wed, 21 Jul 2004 22:51:13 +0000
Subject: Re: Re: change value of session variable?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-191438@lists.php.net to get a copy of this message
"Chris Shiflett" <shiflett@php.net> wrote in message news:20040721222135.94578.qmail@web52807.mail.yahoo.com... > --- Five <primeooze@hotmail.com> wrote: > > page1.php > > <?php > > session_start(); > > echo 'page #1<br>'; > > > > echo $_SESSION['favcolor']; > > $_SESSION['favcolor'] = 'green'; > > > > echo '<br><a href="page2.php">page 2</a>'; > > ?> > > > > ---------------------------------------------------- > > page2.php > > <?php > > session_start(); > > echo 'page #2<br>'; > > > > echo $_SESSION['favcolor']; > > $_SESSION['favcolor'] = 'blue'; > > > > echo '<br><a href="page1.php">page 1</a>'; > > ?> > > > > Actually the above code doesn't initialize the variable as > > either green or blue. It leaves it blank. > > You might want to echo a variable after you set it (page1.php) or after > you change it (page2.php). :-) > > Chris > > ===== > Chris Shiflett - http://shiflett.org/ > > PHP Security - O'Reilly > Coming Fall 2004 > HTTP Developer's Handbook - Sams > http://httphandbook.org/ > PHP Community Site > http://phpcommunity.org/ That did it! I wonder if there is a way, then, to have it work even if the variable is initialized after it is echoed. I was actually trying to do this to pass values in another script. I'm writing some code that has to do with storing and retrieving images in mysql. I'm having trouble passing image information (the kind needed for getimagesize( ) to work) and I can't get session variables to initalize in that either. More experimentation with echo (and other code) placement needed.

« previous php.general (#191438) next »