Re: Help with session

From: Date: Fri, 16 Feb 2001 01:28:40 +0000
Subject: Re: Help with session
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-40048@lists.php.net to get a copy of this message
I think you want the session_start() and session_register() calls at the top of the script, not buried in your if() statements. -- Visit the Zend Store at http://www.zend.com/store/ Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm ----- Original Message ----- From: "Karl J. Stubsjoen" <karlflips@kstub.com> Newsgroups: php.general Sent: Thursday, February 15, 2001 11:36 AM Subject: [PHP] Help with session > I have 2 functions on my page, RegisterUser, IsValidUser. > RegisterUser looks in the querystring to see if you've passed a certain key > & value. If you have it populates a session variable called "ValidUser" > with a 1. > All that IsValidUser does, is check to see if the session variable > "ValidUser" is a 1 or not. > > It doesn't work. > RegisterUser (which sets session variables) is taking place before headers > are written to the browser. I'm not gettin errors, but the problem is that > ValidUser isn't able to read the session variable for some reason. > > Any Ideas? > > Here is the code for these 2 functions: > > function IsValidUser() > { > global $HTTP_SESSION_VARS; > > $reslt = 0; > > if (isset($HTTP_SESSION_VARS["ValidUser"])) > { > if ($HTTP_SESSION_VARS["ValidUser"] == "1") > $reslt = 1; > } > print("ValidUser? " . $HTTP_SESSION_VARS["ValidUser"] . > "<br>"); > > return($reslt); > } > > > function RegisterUser() > { > global $HTTP_SESSION_VARS; > global $HTTP_GET_VARS; > $reslt = 0; > > if (isset($HTTP_SESSION_VARS["ValidUser"])) > { > if ($HTTP_SESSION_VARS["ValidUser"] == 1) > { > $reslt = 1; > } > } > > if ($reslt=0); > { > > $Val_User = $HTTP_GET_VARS["fis"]; > > if ($Val_User == "1") > { > $reslt = 1; > if (!isset($HTTP_SESSION_VARS["ValidUser"])) > { > session_start(); > session_register("ValidUser"); > $HTTP_SESSION_VARS["ValidUser"] = 1; > } > else > { > $HTTP_SESSION_VARS["ValidUser"] = 1; > } > } > else > { > $reslt = 0; > } > } > return($reslt); > } > > > > -- > 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 (#40048) next »