Re: Session Variables

From: Date: Mon, 27 Jan 2003 04:14:07 +0000
Subject: Re: Session Variables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-133215@lists.php.net to get a copy of this message
This variable is registered in the Session, and the variable isn't active until the page refreshes. It's hard to explain. I thought I would try. There are some things you can do. If you need the variable right away, you can do this: if (isset($HTTP_SESSION_VARS["user1"])) { $user1 = $HTTP_SESSION_VARS["user1"]; } else { $user1 = $HTTP_POST_VARS["user1"]; } echo $user1; Hope that helps. This is natural for sessions, but I have been in the situation where I needed the session variable right away, instead of the script's next activation. "Jed R. Brubaker" <jed.brubaker@psych.utah.edu> wrote in message news:20030126230532.45757.qmail@pb1.pair.com... > I have a quirky problem that should be a breeze for someone who is smarter > than I. > > I have a script where I am registering a HTML form post variable as a > session variable and then echo it. In the real script I use it in a MySQL > query, but for the sake of this post, here is the "script": > > $user1 = $HTTP_POST_VARS["user1"]; > session_register("user1"); > echo $HTTP_SESSION_VARS["user1"]; > > This doesn't work, however, if I hit the refresh button the var miraculously > appears! > What am I doing wrong? > >

« previous php.general (#133215) next »