Re: Session Variables

From: Date: Thu, 03 May 2001 20:40:55 +0000
Subject: Re: Session Variables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-51327@lists.php.net to get a copy of this message
Funnily - doesn't work for me. Here's what I got: Script #1 #!/usr/local/bin/php <?php session_start(); if (!isset($count)) { echo "Setting count"; session_register("count"); } else echo $count; $count++; sleep(60); ?> Script #2 #!/usr/local/bin/php <?php session_start(); echo $count; ?> If I start script#1 (and it sleep()s), wait 10 seconds, then launch script #2 in a separate browser window, script #2 returns empty. However once the sleep() is completed and I refresh the window with script #2, the output is okay (1). Why does this happen? Nikhil ""Johnson, Kirk"" <kjohnson@zootweb.com> wrote in message news:01A4B59FD1EBD311838100A0C98BE0D9AD5939@chef.zootweb.com... > > -----Original Message----- > > From: Nikhil Goyal [mailto:ngoyal@nypirg.org] > > > When does a session variable become available? Immediately after the > > session_register command or after the script ends? > > Immediately after it is assigned. > > > And if the commands are as follows: > > > > session_start(); > > session_register("hello"); > > $hello=3; > > > > will the session variable $hello be set to 3 or do I have to > > add another > > session_register() call after changing the value? > > No additional calls are needed. You will need to do session_start() on the > next page if you want to access $hello there. > > Kirk > > -- > 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 (#51327) next »