PHP Session Help

From: Date: Fri, 11 Aug 2000 19:13:10 +0000
Subject: PHP Session Help
Groups: php.general 
Request: Send a blank email to php-general+get-11386@lists.php.net to get a copy of this message
I am trying to find my problem with PHP Session using two experimental pages (see below). The only difference between them is that one should print out the variables if the Sessions correctly work. However, I am only getting the message saying that it started the session (message is given in PHP_SESSION_MANAGER() with $Request = $Logon, one of my user-defined functions). Am I doing anything wrong? I am using Apache 1.3.12 and Php4.0.1pl2. Thanks in advance, code is below. Benjamen R. Meyer <HTML> <SCRIPT LANGUAGE="PHP"> // Function Declarations function PHP_SESSION_RECORDER($Request) { //Saves information to the database (not using for experiment. if ($Request == "LOGON") { } else if ($Request == "LOGOFF") { } } function PHP_SESSION_MANAGER($Request) { if ($Request == "LOGON") //Open The Session { session_start(); session_name("TUX_PHP_SESSION_MANAGER"); session_register($UserData); PHP_SESSION_RECORDER($Request); $UserData["SessionID"] = session_id(); $UserData["LoggedON"] = 1; $UserData["ProcessLogOff"] = 0; echo "<H4>PHP Session Manager: You have now been logged on.</H4>"; } else if ($Request == "LOGOFF") //Close the Session { PHP_SESSION_RECORDER($Request); $UserData["SessionID"] = 0; $UserData["LoggedON"] = 0; $UserData["ProcessLogOff"] = 1; session_unregister($UserData); session_destroy(); echo "<H4>PHP Session Manager: You have now been logged off.</H4>"; } else if ($Request == "UPDATE") //Start A Session From A Previous Session { session_start(); session_name("TUX_PHP_SESSION_MANAGER"); session_id($UserData["SessionID"]); echo "<H4>PHP Session Manager: Session has been re-established.</H4>"; } } function PHP_IS_SESSION_INUSE() { $RetValue = false; if (($UserData["SessionID"] == session_id())) { $RetValue = true; } return $RetValue; } //Variable Declarations //Main Program if (!isset($UserData)) { echo "UserData[SessionID] = " . $UserData["SessionID"] . "<BR>"; echo "UserData[LoggedON] = " . $UserData["LoggedON"] . "<BR>"; echo "UserData[ProcessLogOff] = " . $UserData["ProcessLogOff"] . "<BR>"; echo "UserData[HelpMe] = " . $UserData["HelpMe"] . "<BR>"; } if (!($UserData["ProcessLogOff"]) && isset($UserData)) { PHP_SESSION_MANAGER("LOGOFF"); exit; } else if (!(PHP_IS_SESSION_INUSE())) { if (!($UserData["LoggedON"]) && !(isset($UserData))) { PHP_SESSION_MANAGER("LOGON"); $UserData["HelpMe"] = 1; } else { PHP_SESSION_MANAGER("UPDATE"); $UserData["HelpMe"] = 0; } } if ($UserData["HelpMe"]) { echo "Intruder Alert! Intruder Alert! Security to Deck 14 Section 10."; } </SCRIPT> </HTML>

« previous php.general (#11386) next »