Attempts to restore or set up a session

@param bool $bForceSetup Whether to force session set up
489272
protected function setup($bForceSetup = false)
    {
        if (!empty($this->oSession)) {
            return;
        }

        $oInput = Factory::service('Input');
        //  class_exists check in case the class is called before CI has finished instanciating
        if (!$oInput::isCli() && class_exists('CI_Controller')) {
            /**
             * Look for the session cookie, if it exists, then a session exists
             * and the whole service should be loaded up.
             */
            $oConfig     = Factory::service('Config');
            $sCookieName = $oConfig->item('sess_cookie_name');

            if ($bForceSetup || $oInput::cookie($sCookieName)) {
                //  @todo (Pablo - 2018-03-19) - Remove dependency on CI Sessions
                $oCi = get_instance();
                $oCi->load->library('session');
                if (empty($oCi->session)) {
                    throw new NailsException('Failed to load CodeIgniter session library.');
                }
                $this->oSession = $oCi->session;
            }
        }
    }
588381
public static function GetInstance($bReset = false, $bReloadFromSession = false)
    {
        /** @var $shopService ShopServiceInterface */
        $shopService = \ChameleonSystem\CoreBundle\ServiceLocator::get('chameleon_system_shop.shop_service');
        if ($bReset) {
            $shopService->resetBasket();
        }

        return $shopService->getActiveBasket();
    }
551167
public static function restore($clear = true)
    {
        if ($clear) {
            libxml_clear_errors();
        }

        libxml_use_internal_errors(self::$internalErrors);
        libxml_disable_entity_loader(self::$disableEntities);
    }
44541
def restore_session(self):
        

        session = [foundations.strings.to_string(path)
                   for path in self.__settings.get_key(self.__settings_section, "session").toStringList()
                   if foundations.common.path_exists(path)]

        LOGGER.debug("> Restoring session :'{0}'.".format(session))
        success = True
        for path in session:
            if os.path.isfile(path):
                success *= self.load_file(path)
            else:
                success *= self.add_project(path)
        return success
902637
protected function setUserSessionBackup()
    {
        $this->userSessionBackup = isset($_SESSION[self::SESSION_PARAMETER_CLOUDCONTROL]) ? $_SESSION[self::SESSION_PARAMETER_CLOUDCONTROL] : null;
        $fakeUser = new \stdClass();
        $fakeUser->username = self::SESSION_PARAMETER_FORM_COMPONENT;
        $_SESSION[self::SESSION_PARAMETER_CLOUDCONTROL] = $fakeUser;
    }
551626
public function setSuperUserAccess($bool = true)
    {
        $this->hasSuperUserAccess = (bool) $bool;

        if ($bool) {
            $this->makeSureLoginNameIsSet();
        } else {
            $this->resetSites();
        }
    }
919828
public function restoreCommand($selectedBackup = null)
    {
        $this->initialize();

        if (is_null($selectedBackup)) {
            $availableVersions = $this->backupService->getAvailableVersions();

            if ( count($availableVersions)<=0 ) {
                $this->output->outputLine();
                $this->output->outputLine('<b>You have no Backups!</b>');
                $this->output->outputLine();
                $this->output->outputLine('Call \'./flow backup:now\' and create one.');
                $this->output->outputLine();
                return;
            }

            $selectedBackup = $this->askWithSelectForVersion($availableVersions);
        }

        $this->backupService->restoreBackup($selectedBackup);
    }
427956
public static function configure($memcacheContainer = null) {
    $handler = new MemcacheSessionHandler($memcacheContainer);

    session_set_save_handler($handler, true);

    /**
     * Set so that it is clear that Memcache is being used for session handling,
     * as retrieving session.save_handler just returns "user".
     */
    session_save_path("Memcache");
  }
129060
function _connect(&$fp)
    {
        if (!empty($this->proxy_host) && !empty($this->proxy_port)) {
            $this->_isproxy = true;

            $host = $this->proxy_host;
            $port = $this->proxy_port;

            if ($this->scheme == 'https') {
                trigger_error("HTTPS connections over proxy are currently not supported", E_USER_ERROR);
                exit;
            }
        } else {
            $host = $this->host;
            $port = $this->port;
        }

        $this->status = 0;

        $context_opts = array();

        if ($this->scheme == 'https') {
            // if cafile or capath is specified, enable certificate
            // verification (including name checks)
            if (isset($this->cafile) || isset($this->capath)) {
                $context_opts['ssl'] = array(
                    'verify_peer' => true,
                    'CN_match' => $this->host,
                    'disable_compression' => true,
                );

                if (isset($this->cafile))
                    $context_opts['ssl']['cafile'] = $this->cafile;
                if (isset($this->capath))
                    $context_opts['ssl']['capath'] = $this->capath;
            }
                    
            $host = 'ssl://' . $host;
        }

        $context = stream_context_create($context_opts);

        if (version_compare(PHP_VERSION, '5.0.0', '>')) {
            if($this->scheme == 'http')
                $host = "tcp://" . $host;
            $fp = stream_socket_client(
                "$host:$port",
                $errno,
                $errmsg,
                $this->_fp_timeout,
                STREAM_CLIENT_CONNECT,
                $context);
        } else {
            $fp = fsockopen(
                $host,
                $port,
                $errno,
                $errstr,
                $this->_fp_timeout,
                $context);
        }

        if ($fp) {
            // socket connection succeeded
            return true;
        } else {
            // socket connection failed
            $this->status = $errno;
            switch ($errno) {
                case -3:
                    $this->error = "socket creation failed (-3)";
                case -4:
                    $this->error = "dns lookup failure (-4)";
                case -5:
                    $this->error = "connection refused or timed out (-5)";
                default:
                    $this->error = "connection failed (" . $errno . ")";
            }
            return false;
        }
    }
1369164
public function onPreRestore(PreRestoreEvent $event)
    {
        $systemDatabase = $event->getSystemDatabase();
        if ($systemDatabase->getWithDefault('state', BackupStatus::STATE_SUCCESS) === BackupStatus::STATE_PARTIALLY
            && !$this->environment->restorePartiallyBackup()
        ) {
            $event->cancel();
        }
    }
1226336
public function onRestoreStarted(RestoreEvent $event)
    {
        $database = $event->getDatabase();
        if ($database->getWithDefault('state', BackupStatus::STATE_SUCCESS) === BackupStatus::STATE_FAILED) {
            $this->output->writeln('  <info>Bypassed</info>');

            $event->stopPropagation();
        }
    }
1045712
public static function Set($sRoute, $sRequestType = "GET", $fCallback){
            $oThis = self::CreateInstanceIfNotExists();
            $oThis->aRoutes[$sRequestType."_".strtolower($sRoute)] = $fCallback;
        }
1215810
private function setup($force = false)
    {
        // Set a default error code to indicate if anything changes
        $this->errorCode = NULL;

        // Indicate if this is a forced procedure
        $this->force = $force;

        // Load the current user
        $this->getUser();

        // Get the current bcrypt cost
		$this->_cost = Cii::getBcryptCost();

        // Preload the number of password attempts. As of 1.10.0
        $this->getPasswordAttempts();

        return;
    }
462494
public function resetSignInLock()
    {
        $nb_session = $this->nb_application->getSession();
        if ($nb_session === null || !($nb_session instanceof CNabuHTTPSession)) {
            throw new ENabuCoreException(ENabuCoreException::ERROR_SESSION_NOT_FOUND);
        }

        $nb_session->unsetVariable('signin_retries');
        $nb_session->unsetVariable('signin_last_fail_timestamp');
    }
891010
public static function SetOverloadFrontend($bStatus = false){
            $oThis = self::CreateInstanceIfNotExists();
            
            if(is_bool($bStatus))
                $oThis->bOverloadFrontend = $bStatus;
        }
1182608
protected function restoreUserSessionBackup()
    {
        if ($this->userSessionBackup === null) {
            unset($_SESSION[self::SESSION_PARAMETER_CLOUDCONTROL]);
        } else {
            $_SESSION[self::SESSION_PARAMETER_CLOUDCONTROL] = $this->userSessionBackup;
        }
    }
234919
protected function sessionStart($force_start = true)
    {
        if ($this->sessionStarted) {
            return;
        }
        $this->sessionStarted = true;
        if (!$this instanceof \PHPDaemon\HTTPRequest\Generic) {
            Daemon::log('Called ' . get_class($this) . '(trait \PHPDaemon\Traits\Sessions)->sessionStart() outside of Request. You should use onSessionStart.');
            return;
        }
        $f = true; // hack to avoid a sort of "race condition"
        $this->onSessionStart(function ($event) use (&$f) {
            $f = false;
            $this->wakeup();
        });
        if ($f) {
            $this->sleep($this->sessionStartTimeout);
        }
    }