Anyway, I've implemented a class to help manage the $_SESSION superglobal so that multiple modules can maintain session variables without worrying that another module will overwrite them.
//Helps manage session variables across multiple modules //As with the databases, each variable's name is managed to ensure that it //is unique class SessionManager { //Tests if the variable exists function IsSet($variable, $owner_name) { return isset($_SESSION[this->GetName($variable, $owner_name)]); } //Accessor functions function Get($variable, $owner_name) { return $_SESSION[this->GetName($variable, $owner_name)]; } //Allows a user to quickly copy variables from an array like $_POST function SetFromArray($variables, $owner_name) { foreach ($variables as $key => $value) { $_SESSION[this->GetName[$key, $owner_name]] = $value; } } function Set($variable, $value, $owner_name) { $_SESSION[this->GetName[$variable, $owner_name]] = $value; } //Name mangler function GetName($variable, $owner_name) { return $owner_name . '_' . $variable; } }
This class might change a bit since I am unsure of the affect of Magic Quotes on $_SESSION. It know that magic quotes will be added but I am unsure what would happen if I did something like this in GetRequestVars()
$_SESSION['variable'] = stripslashes($_SESSION['variable']);
Will $_SESSION become reslashed when I go to a new file and use the same session? The whole Magic Quotes thing seems to add an unnecessarly layer of complexity.