12/3/2013 5:04:31 AM

The following is a simple wrapper class to work with PHP sessions.

*You need to call session_start(); on every page you need session acccess. Maybe the following could be added to this class to ensure the session is started.

if(!isset($_SESSION))
{
     session_start();
}


<?php namespace Common; class Session { public static function Clear() { if(!isset($_SESSION)) { session_destroy(); } } public static function GetValue($key, $default = null) { $key = strtolower($key); if (isset($_SESSION[$key])) { return $_SESSION[$key]; } return $default; } public static function SetValue($key, $value) { $key = strtolower($key); //print_r($_SESSION); $_SESSION[$key] = $value; } } ?>