Current Progress

posted in Rarely Spoken
Published January 12, 2005
Advertisement
I've been working on the administration module during the past few days and while working on it I've been really wishing that my host would upgrade to PHP 5. It would be very nice if I could give QueryResult and Database destructors so that I didn't have to remember to call QueryResult::FreeResult() and Database::Disconnect() everytime there is an error. Unfortunately my host probably wont upgrade to PHP 5 for at least a year (my best guess). [headshake]

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.
Previous Entry Finally - Some Code
Next Entry Some More Progress
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement

Latest Entries

4E6 PyGame

1275 views

4E5

1023 views

Happy Yesterday!

978 views

Another Game

1172 views

Merry Christmas!

952 views

Hello There

957 views

Yay!

962 views
Advertisement