1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- /** @package verysimple::HTTP */
- /**
- * Context Persistance Storage
- *
- * The context provides an object that can be uses globally for
- * dependency injection when passing information that should be
- * available to an entire application
- *
- * @package verysimple::HTTP
- * @author VerySimple Inc.
- * @copyright 1997-2007 VerySimple, Inc. http://www.verysimple.com
- * @license http://www.gnu.org/licenses/lgpl.html LGPL
- * @version 1.0
- */
- class Context
- {
- public $GUID;
-
- /**
- * Constructor initializes the session
- */
- public function __construct()
- {
- if (session_id() == '')
- {
- @session_start();
- }
- }
-
- /**
- * Returns a persisted object or value
- *
- * @param var
- * @param default value (default = null)
- * @return value of var (or default)
- */
- public function Get($var,$default = null)
- {
- return (isset($_SESSION[$this->GUID . "_" . $var])) ? unserialize($_SESSION[$this->GUID . "_" . $var]) : null;
- }
- /**
- * Persists an object or value
- *
- * @access public
- * @param var
- * @param value
- * @return object || null
- */
- public function Set($var,$val)
- {
- $_SESSION[$this->GUID . "_" . $var] = serialize($val);
- }
- }
- ?>
|