Initializes session handler.

@return mixed
321776
public static function init()
    {
        $c = new Configuration();
        $cc = $c->from('app')->get('session');

        if (strtolower($cc) == 'session') {
            return new Session();
        } elseif (strtolower($cc) == 'file') {
            return new File();
        } elseif (strtolower($cc) == 'cookie') {
            return new Cookie();
        } else {
            throw new \Exception($cc.' is not a supported session type!');
        }
    }
1121174
public static function init() {

        if (self::$_sessionStarted == false) {

            self::start();
            self::$_sessionStarted = true;
        }

        // Thanks Jon - http://stackoverflow.com/questions/8311320/how-to-change-the-session-timeout-in-php
        $now = time();
        if (isset($_SESSION['expiration_time']) && $now > $_SESSION['expiration_time']) {

            self::destroy();
            self::start();
        }

        $timeout = 3600;
        if (!empty(Config::get('session', 'timeout'))) {

            $timeout = Config::get('session', 'timeout');
        }

        $_SESSION['expiration_time'] = $now + $timeout;
    }
72229
public function getSession() {
        if ($this->debug) { $start = microtime(true); }
        if (!$this->sessionLoaded) {
            $session = null;
            $write_cookie = true;

            $parsed_url = parse_url($this->redirect_uri);
            $parsed_path = '/';
            if (!empty($parsed_url['path'])) {
                $parsed_path = ($parsed_url['path'] != '/')?rtrim($parsed_url['path'], '/'):'/';
            }
            $request_uri = $this->_getServerParam('REQUEST_URI');
            $code = $this->_getRequestParam('code');
            if (!$session && stristr($request_uri,$parsed_path) && $code) {
                $ret = $this->getAccessToken($code);
                if (is_array($ret) && isset($ret['access_token'])) {
                    $session = $this->signSession($ret); // Signs session for security
                }
            }
            // try loading session from signed_request in $_REQUEST
            $signedRequest = $this->getSignedRequest();
            if ($signedRequest) {
                // sig is good, use the signedRequest
                $session = $this->createSessionFromSignedRequest($signedRequest);
            }
            // try loading session from $_REQUEST
            $session_param = $this->_getRequestParam('session');
            if (!$session && $session_param) {
                $session = json_decode(get_magic_quotes_gpc() ? stripslashes($session_param) : $session_param, true);
                $session = $this->validateSessionObject($session);
            }
            // try loading session from cookie if necessary
            if (!$session && $this->useCookieSupport()) {
                $cookieName = $this->getSessionCookieName();
                if (isset($_COOKIE[$cookieName])) {
                    $session = array();
                    parse_str(trim(get_magic_quotes_gpc() ? stripslashes($_COOKIE[$cookieName]) : $_COOKIE[$cookieName], '"'), $session);
                    $session = $this->validateSessionObject($session);
                    // write only if we need to delete a invalid session cookie
                    $write_cookie = empty($session);
                }
            }
            $this->setSession($session, $write_cookie);
        }
        if ($this->debug) { $this->timer[__FUNCTION__]['elapsed'][] = microtime(true)-$start; }
        return $this->session;
    }
1116257
public static function getSession()
    {
        if (CNabuHTTPSession::$nb_session === null) {
            CNabuHTTPSession::$nb_session = new CNabuHTTPSession();
            CNabuHTTPSession::$nb_session->init();
        }

        return CNabuHTTPSession::$nb_session;
    }
813335
private function initialize()
    {
        $this->name = (isset($this->configurations['name']))
            ? $this->configurations['name']
            : self::DEFAULT_SESSION_NAME;
        $this->assignSessionLifetime();
        if (isset($this->configurations['encryption_enabled'])
            && $this->configurations['encryption_enabled']) {
            $this->handler = new EncryptedSessionHandler();
        }
        $this->security = new SecuritySession($this->configurations);
    }
1125346
private function initialSessionStart()
    {
        if (!is_null($this->decoy)) {
            $this->decoy->throwDecoys();
        }
        $_SESSION['__HANDLER_INITIATED'] = true;
        return false;
    }
648485
protected function buildSession($handler)
    {
        return $this->app['config']['session.encrypt']
                ? $this->buildEncryptedSession($handler)
                : new Store($this->app['config']['session.cookie'], $handler);
    }
309495
protected function init()
    {
        // If there’s no session header yet, this means we haven’t yet logged in
        if (!$this->getSessionHeader()) {
            $this->doLogin($this->username, $this->password, $this->token);
        }
    }
1133992
public static function initialize()
    {
        if (static::$isConfigurationLoaded === true) {
            return;
        }
        
        foreach (static::$handlers as $handler) {
            EventManager::getInstance()->addEventHandler($handler[0], $handler[1], $handler[2], $handler[3]);
        }

        static::$isConfigurationLoaded = true;
    }
1135367
public function init()
    {
        parent::init();
        $this->matchCallback = function () {
            return !User::can($this->perm);
        };
        $this->denyCallback = function () {
            Yii::$app->session->addFlash('danger', Yii::t('podium/flash', 'You are not allowed to perform this action.'), true);
            return Yii::$app->response->redirect([Podium::getInstance()->prepareRoute($this->redirect)]);
        };
    }
348301
public static function start() {
        global $CFG, $DB, $PERF;

        if (isset(self::$sessionactive)) {
            debugging('Session was already started!', DEBUG_DEVELOPER);
            return;
        }

        // Grab the time before session lock starts.
        $PERF->sessionlock['start'] = microtime(true);
        self::load_handler();

        // Init the session handler only if everything initialised properly in lib/setup.php file
        // and the session is actually required.
        if (empty($DB) or empty($CFG->version) or !defined('NO_MOODLE_COOKIES') or NO_MOODLE_COOKIES or CLI_SCRIPT) {
            self::$sessionactive = false;
            self::init_empty_session();
            return;
        }

        try {
            self::$handler->init();
            self::prepare_cookies();
            $isnewsession = empty($_COOKIE[session_name()]);

            if (!self::$handler->start()) {
                // Could not successfully start/recover session.
                throw new \core\session\exception(get_string('servererror'));
            }

            // Grab the time when session lock starts.
            $PERF->sessionlock['gained'] = microtime(true);
            $PERF->sessionlock['wait'] = $PERF->sessionlock['gained'] - $PERF->sessionlock['start'];
            self::initialise_user_session($isnewsession);
            self::$sessionactive = true; // Set here, so the session can be cleared if the security check fails.
            self::check_security();

            // Link global $USER and $SESSION,
            // this is tricky because PHP does not allow references to references
            // and global keyword uses internally once reference to the $GLOBALS array.
            // The solution is to use the $GLOBALS['USER'] and $GLOBALS['$SESSION']
            // as the main storage of data and put references to $_SESSION.
            $GLOBALS['USER'] = $_SESSION['USER'];
            $_SESSION['USER'] =& $GLOBALS['USER'];
            $GLOBALS['SESSION'] = $_SESSION['SESSION'];
            $_SESSION['SESSION'] =& $GLOBALS['SESSION'];

        } catch (\Exception $ex) {
            self::init_empty_session();
            self::$sessionactive = false;
            throw $ex;
        }
    }
100355
public static function initialize()
    {
        if (!isset($GLOBALS['_SESSION']) or !($GLOBALS['_SESSION'] instanceof self)) {
            $GLOBALS['_SESSION'] = self::getInstance();
        }

        return self::getInstance();
    }
152761
public function initSession()
    {
        $sessionManager = new SessionManager();
        $sessionManager->start();
        Container::setDefaultManager($sessionManager);
        $container = new Container('melisinstaller');

    }
1321297
public function init()
    {
        $this->initSession();
        $this->session = null === $_SESSION ? array() : $_SESSION;
        if (NULL === $this->getSessionKey('__FLASH_CLEAR__')) {
            $this->clearFlashes();
            $this->setSessionKey('__FLASH_CLEAR__', microtime(TRUE));
        }
        $this->user = array_key_exists(self::USER_ID_TOKEN, $this->session) ? unserialize($this->session[self::USER_ID_TOKEN]) : NULL;
        $this->admin = array_key_exists(self::ADMIN_ID_TOKEN, $this->session) ? unserialize($this->session[self::ADMIN_ID_TOKEN]) : NULL;
        if (null === $this->admin) {
            $this->checkAdmin();
        }
        $this->setLoaded(true);
    }
1162646
private function loadSession() {

		$session = &$_SESSION;
		
		$this->sessionDataBag->initialize($session);

		$this->started = TRUE;

	}
934346
public function session ()
	{
		
		if (!($this->session instanceof Session))
		{
			$this->session	= Session::singleton ($this->sessionID);
		}
		
		return $this->session;
		
	}
475369
public function startHTTPSession()
    {
        // @codeCoverageIgnoreStart
        // Safety measure - can't test this without replacing PHP
        if (session_status() === PHP_SESSION_DISABLED)
            throw new \RuntimeException("Sesssions are disabled");
        // @codeCoverageIgnoreEnd

        if (session_status() === PHP_SESSION_ACTIVE)
            throw new \LogicException("Repeated session initialization");

        // Now do the PHP session magic to initialize the $_SESSION array
        session_set_cookie_params(
            $this->lifetime, 
            $this->session_cookie->getPath(),
            $this->session_cookie->getDomain(),
            $this->session_cookie->getSecure(),
            $this->session_cookie->getHTTPOnly()
        );
        session_name($this->session_cookie->getName());

        $custom_session_id = defined('WEDETO_TEST') && WEDETO_TEST === 1 && $this->session_id !== null;
        if ($custom_session_id)
        {
            ini_set('session.use_strict_mode', 0);
            session_id($this->session_id);
        }
            
        session_start();

        if ($custom_session_id)
            ini_set('session.use_strict_mode', 1);

        // Store the session ID
        $this->session_id = session_id();

        // Make sure the session data is accessible through this object
        $this->values = &$_SESSION;

        // Check if session was regenerated
        $this->secureSession();

        // PHPs sessions do not renew the cookie, so it will expire after the
        // period set when the session was first created. We want to postpone
        // the session expiry at every request, so force a cookie to be sent.
        // As the session_id is available after the session started, we need to
        // update the cookie that was generated in the constructor.
        $this->session_cookie->setValue(session_id());

        // Session has been started
        $this->active = true;

        return $this;
    }