/** * __construct() - Returns an instance object bound to a particular, isolated section * of the session, identified by $namespace name (defaulting to 'Default'). * The optional argument $singleInstance will prevent construction of additional * instance objects acting as accessors to this $namespace. * * @param string $namespace - programmatic name of the requested namespace * @param bool $singleInstance - prevent creation of additional accessor instance objects for this namespace * @return void */ public function __construct($namespace = 'Default', $singleInstance = false) { if ($namespace === '') { /** * @see IfwPsn_Vendor_Zend_Session_Exception */ require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Session/Exception.php'; throw new IfwPsn_Vendor_Zend_Session_Exception('Session namespace must be a non-empty string.'); } if ($namespace[0] == "_") { /** * @see IfwPsn_Vendor_Zend_Session_Exception */ require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Session/Exception.php'; throw new IfwPsn_Vendor_Zend_Session_Exception('Session namespace must not start with an underscore.'); } if (preg_match('#(^[0-9])#i', $namespace[0])) { /** * @see IfwPsn_Vendor_Zend_Session_Exception */ require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Session/Exception.php'; throw new IfwPsn_Vendor_Zend_Session_Exception('Session namespace must not start with a number.'); } if (isset(self::$_singleInstances[$namespace])) { /** * @see IfwPsn_Vendor_Zend_Session_Exception */ require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Session/Exception.php'; throw new IfwPsn_Vendor_Zend_Session_Exception("A session namespace object already exists for this namespace ('{$namespace}'), and no additional accessors (session namespace objects) for this namespace are permitted."); } if ($singleInstance === true) { self::$_singleInstances[$namespace] = true; } $this->_namespace = $namespace; // Process metadata specific only to this namespace. IfwPsn_Vendor_Zend_Session::start(true); // attempt auto-start (throws exception if strict option set) if (self::$_readable === false) { /** * @see IfwPsn_Vendor_Zend_Session_Exception */ require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Session/Exception.php'; throw new IfwPsn_Vendor_Zend_Session_Exception(self::_THROW_NOT_READABLE_MSG); } if (!isset($_SESSION['__ZF'])) { return; // no further processing needed } // do not allow write access to namespaces, after stop() or writeClose() if (parent::$_writable === true) { if (isset($_SESSION['__ZF'][$namespace])) { // Expire Namespace by Namespace Hop (ENNH) if (isset($_SESSION['__ZF'][$namespace]['ENNH'])) { $_SESSION['__ZF'][$namespace]['ENNH']--; if ($_SESSION['__ZF'][$namespace]['ENNH'] === 0) { if (isset($_SESSION[$namespace])) { self::$_expiringData[$namespace] = $_SESSION[$namespace]; unset($_SESSION[$namespace]); } unset($_SESSION['__ZF'][$namespace]); } } // Expire Namespace Variables by Namespace Hop (ENVNH) if (isset($_SESSION['__ZF'][$namespace]['ENVNH'])) { foreach ($_SESSION['__ZF'][$namespace]['ENVNH'] as $variable => $hops) { $_SESSION['__ZF'][$namespace]['ENVNH'][$variable]--; if ($_SESSION['__ZF'][$namespace]['ENVNH'][$variable] === 0) { if (isset($_SESSION[$namespace][$variable])) { self::$_expiringData[$namespace][$variable] = $_SESSION[$namespace][$variable]; unset($_SESSION[$namespace][$variable]); } unset($_SESSION['__ZF'][$namespace]['ENVNH'][$variable]); } } if (empty($_SESSION['__ZF'][$namespace]['ENVNH'])) { unset($_SESSION['__ZF'][$namespace]['ENVNH']); } } } if (empty($_SESSION['__ZF'][$namespace])) { unset($_SESSION['__ZF'][$namespace]); } if (empty($_SESSION['__ZF'])) { unset($_SESSION['__ZF']); } } }