Help with session

From: Date: Thu, 15 Feb 2001 17:31:39 +0000
Subject: Help with session
Groups: php.general 
Request: Send a blank email to php-general+get-39952@lists.php.net to get a copy of this message
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); }

« previous php.general (#39952) next »