Skip to content
This repository
tree: b16313ab3b
Fetching contributors…

Cannot retrieve contributors at this time

file 33 lines (28 sloc) 0.817 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
<?PHP
    // Stores session variables unique to a given URL
    class PagePref
    {
        public $_id;
        public $_data;

        public function __construct()
        {
            $this->_id = 'pp' . md5($_SERVER['PHP_SELF']);

            if(isset($_SESSION[$this->_id]))
                $this->_data = unserialize($_SESSION[$this->_id]);
        }

        public function __get($key)
        {
            return $this->_data[$key];
        }

        public function __set($key, $val)
        {
            if(!is_array($this->_data)) $this->_data = array();
            $this->_data[$key] = $val;
            $_SESSION[$this->_id] = serialize($this->_data);
        }

        public function clear()
        {
            unset($_SESSION[$this->_id]);
            unset($this->_data);
        }
    }
Something went wrong with that request. Please try again.