Example #1
0
 /**
  * start() - Start the session.
  *
  * @param bool|array $options  OPTIONAL Either user supplied options, or flag indicating if start initiated automatically
  * @throws IfwPsn_Vendor_Zend_Session_Exception
  * @return void
  */
 public static function start($options = false)
 {
     // Check to see if we've been passed an invalid session ID
     if (self::getId() && !self::_checkId(self::getId())) {
         // Generate a valid, temporary replacement
         self::setId(md5(self::getId()));
         // Force a regenerate after session is started
         self::$_regenerateIdState = -1;
     }
     if (self::$_sessionStarted && self::$_destroyed) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Session/Exception.php';
         throw new IfwPsn_Vendor_Zend_Session_Exception('The session was explicitly destroyed during this request, attempting to re-start is not allowed.');
     }
     if (self::$_sessionStarted) {
         return;
         // already started
     }
     // make sure our default options (at the least) have been set
     if (!self::$_defaultOptionsSet) {
         self::setOptions(is_array($options) ? $options : array());
     }
     // In strict mode, do not allow auto-starting IfwPsn_Vendor_Zend_Session, such as via "new IfwPsn_Vendor_Zend_Session_Namespace()"
     if (self::$_strict && $options === true) {
         /** @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('You must explicitly start the session with IfwPsn_Vendor_Zend_Session::start() when session options are set to strict.');
     }
     $filename = $linenum = null;
     if (!self::$_unitTestEnabled && headers_sent($filename, $linenum)) {
         /** @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 must be started before any output has been sent to the browser;" . " output started in {$filename}/{$linenum}");
     }
     // See http://www.php.net/manual/en/ref.session.php for explanation
     if (!self::$_unitTestEnabled && defined('SID')) {
         /** @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 has already been started by session.auto-start or session_start()');
     }
     /**
      * Hack to throw exceptions on start instead of php errors
      * @see http://framework.zend.com/issues/browse/ZF-1325
      */
     $errorLevel = is_int(self::$_throwStartupExceptions) ? self::$_throwStartupExceptions : E_ALL;
     /** @see IfwPsn_Vendor_Zend_Session_Exception */
     if (!self::$_unitTestEnabled) {
         if (self::$_throwStartupExceptions) {
             require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Session/Exception.php';
             set_error_handler(array('IfwPsn_Vendor_Zend_Session_Exception', 'handleSessionStartError'), $errorLevel);
         }
         $startedCleanly = session_start();
         if (self::$_throwStartupExceptions) {
             restore_error_handler();
         }
         if (!$startedCleanly || IfwPsn_Vendor_Zend_Session_Exception::$sessionStartError != null) {
             if (self::$_throwStartupExceptions) {
                 set_error_handler(array('IfwPsn_Vendor_Zend_Session_Exception', 'handleSilentWriteClose'), $errorLevel);
             }
             session_write_close();
             if (self::$_throwStartupExceptions) {
                 restore_error_handler();
                 throw new IfwPsn_Vendor_Zend_Session_Exception(__CLASS__ . '::' . __FUNCTION__ . '() - ' . IfwPsn_Vendor_Zend_Session_Exception::$sessionStartError);
             }
         }
     }
     parent::$_readable = true;
     parent::$_writable = true;
     self::$_sessionStarted = true;
     if (self::$_regenerateIdState === -1) {
         self::regenerateId();
     }
     // run validators if they exist
     if (isset($_SESSION['__ZF']['VALID'])) {
         self::_processValidators();
     }
     self::_processStartupMetadataGlobal();
 }