/** * @param string $namespace * @param bool $readOnly * @return \Zend_Session_Namespace * @throws \Zend_Session_Exception */ public static function get($namespace = "pimcore_admin", $readOnly = false) { $initSession = !\Zend_Session::isStarted(); $forceStart = !$readOnly; // we don't force the session to start in read-only mode (default behavior) $sName = self::getOption("name"); if (self::backupForeignSession()) { $initSession = true; $forceStart = true; } if ($initSession) { \Zend_Session::setOptions(self::$options); } try { try { if ($initSession) { // only set the session id if the cookie isn't present, otherwise Set-Cookie is always in the headers if (array_key_exists($sName, $_REQUEST) && !empty($_REQUEST[$sName]) && (!array_key_exists($sName, $_COOKIE) || empty($_COOKIE[$sName]))) { // get zend_session work with session-id via get (since SwfUpload doesn't support cookies) \Zend_Session::setId($_REQUEST[$sName]); } } } catch (\Exception $e) { \Logger::error("Problem while starting session"); \Logger::error($e); } } catch (\Exception $e) { \Logger::emergency("there is a problem with admin session"); die; } if ($initSession) { \Zend_Session::start(); } if ($forceStart) { @session_start(); self::$sessionCookieCleanupNeeded = true; } if (!array_key_exists($namespace, self::$sessions) || !self::$sessions[$namespace] instanceof \Zend_Session_Namespace) { try { self::$sessions[$namespace] = new Session\Container($namespace); } catch (\Exception $e) { // invalid session, regenerate the session, and return a dummy object \Zend_Session::regenerateId(); return new \stdClass(); } } self::$openedSessions++; self::$sessions[$namespace]->unlock(); return self::$sessions[$namespace]; }
/** * @param string $namespace * @param bool $readOnly * @return \stdClass * @throws \Zend_Session_Exception */ public static function get($namespace = "pimcore_admin", $readOnly = false) { self::initSession(); if (!\Zend_Session::isStarted()) { \Zend_Session::start(); } if (!$readOnly) { // we don't force the session to start in read-only mode @session_start(); self::$sessionCookieCleanupNeeded = true; } if (!array_key_exists($namespace, self::$sessions) || !self::$sessions[$namespace] instanceof \Zend_Session_Namespace) { try { self::$sessions[$namespace] = new \Zend_Session_Namespace($namespace); } catch (\Exception $e) { // invalid session, regenerate the session, and return a dummy object \Zend_Session::regenerateId(); return new \stdClass(); } } self::$openedSessions++; return self::$sessions[$namespace]; }