@param $sessionId

@return Session
971381
protected function getSession($sessionId)
    {
        $session = $this->repository->findOneBy([
            'sessionId' => $sessionId,
        ]);

        if (!$session) {
            $session = $this->getNewInstance($sessionId);
        }

        return $session;
    }
1323498
public static function popSessionCookie(string $sessionName, string $sessionId): ?string
    {
        $sessionCookie = null;
        $sessionCookiePrefix = sprintf(' %s=', urlencode($sessionName));
        $sessionCookieWithId = sprintf('%s%s;', $sessionCookiePrefix, urlencode($sessionId));
        $otherCookies = [];
        foreach (headers_list() as $h) {
            if (0 !== stripos($h, 'Set-Cookie:')) {
                continue;
            }
            if (11 === strpos($h, $sessionCookiePrefix, 11)) {
                $sessionCookie = $h;

                if (11 !== strpos($h, $sessionCookieWithId, 11)) {
                    $otherCookies[] = $h;
                }
            } else {
                $otherCookies[] = $h;
            }
        }
        if (null === $sessionCookie) {
            return null;
        }

        header_remove('Set-Cookie');
        foreach ($otherCookies as $h) {
            header($h, false);
        }

        return $sessionCookie;
    }
258233
public function getAttemptsLeftWithSameSession(string $sessionId): int
    {
        $attemptsLeft = ((int) $this->maxAttemptsForSessionId) - $this->enhancedAuthenticationMapper->fetchAttemptsWithSameSession($sessionId, $this->banTimeInSeconds);

        return \max(0, $attemptsLeft);
    }
1360797
@Nonnull
	public String createSessionId( @Nonnull final String sessionId ) {
		return isEncodeNodeIdInSessionId() ? _sessionIdFormat.createSessionId(sessionId,  _nodeIdService.getMemcachedNodeId() ) : sessionId;
	}
1125254
public function setSessionID(string $session_id)
    {
        if (!defined('WEDETO_TEST') || WEDETO_TEST === 0)
            throw new \RuntimeException("Cannot change the session ID");

        $this->session_id = $session_id;
        return $this;
    }
119703
public function listStreams($sessionId)
    {
        Validators::validateSessionIdBelongsToKey($sessionId, $this->apiKey);
      
        // make API call
        $streamListData = $this->client->listStreams($sessionId);
        return new StreamList($streamListData);
    
    }
1068163
private static function setSessionId($sessionId){
        $sessionId = trim($sessionId);

        // 非法字符处理
        if (!$sessionId || preg_match("/[^0-9a-z_\\-\\,]/i", $sessionId)) {
            return false;
        }

        $sessionId = substr($sessionId, 0, 40);
        session_id($sessionId);

        return $sessionId;
    }
655890
public function session_write($sessionId, $sessionData)
    {
        $sessionData       = (!$sessionData || !is_array($sessionData)) ? [] : $sessionData;
        $this->sessionData = (!$this->sessionData) ? [] : $this->sessionData;

        $this->sessionData = array_merge($sessionData, $this->sessionData);
        $this->engine->set($this->sessionKey . $sessionId, $this->sessionData, $this->sessionLifeTime);

        return true;
    }
578968
private function _getSession($sessionId)
    {
        if (is_null($this->_session)) {
            $this->_session = $this->_repository->find(array('sessionId' => $sessionId));
        }

        return $this->_session;
    }
1141343
public function retrieve($sessionId)
    {
        try {

            $stream = $this->getRetrievalStream($sessionId);
            $stream->open();
            $access = $this->createBinaryStreamAccess($stream);

            // -- Deal with intrinsic values of the Test Session.
            $assessmentTestSessionState = $access->readTinyInt();
            $currentPosition = $access->readTinyInt();

            if ($access->readBoolean() === true) {
                $timeReference = $access->readDateTime();
            } else {
                $timeReference = null;
            }
            
            $visitedTestPartIdentifiers = array();
            $visitedTestPartIdentifiersCount = $access->readTinyInt();
            for ($i = 0; $i < $visitedTestPartIdentifiersCount; $i++) {
                $visitedTestPartIdentifiers[] = $access->readString();
            }
            
            $path = $access->readPath();
            
            // -- Session configuration.
            $config = $access->readShort();

            // Build the route and the item sessions.
            $route = new Route();
            $lastOccurenceUpdate = new SplObjectStorage();
            $itemSessionStore = new AssessmentItemSessionStore();
            $pendingResponseStore = new PendingResponseStore();
            $routeCount = $access->readTinyInt();

            // Create the item session factory that will be used to instantiate
            // new item sessions.
            
            $seeker = $this->getSeeker();

            for ($i = 0; $i < $routeCount; $i++) {
                $routeItem = $access->readRouteItem($seeker);
                $route->addRouteItemObject($routeItem);
                
                // An already instantiated session for this route item?
                if ($access->readBoolean() === true) {
                    $itemSession = $access->readAssessmentItemSession($this->getManager(), $seeker);
                    
                    // last-update
                    if ($access->readBoolean() === true) {
                        $lastOccurenceUpdate[$routeItem->getAssessmentItemRef()] = $routeItem->getOccurence();
                    }
                    
                    // pending-responses
                    if ($access->readBoolean() === true) {
                        $pendingResponseStore->addPendingResponses($access->readPendingResponses($seeker));
                    }

                    $itemSessionStore->addAssessmentItemSession($itemSession, $routeItem->getOccurence());
                }
            }

            $route->setPosition($currentPosition);
            $manager = $this->getManager();
            $assessmentTestSession = $manager->createAssessmentTestSession($this->getAssessmentTest(), $route, $config);
            $assessmentTestSession->setAssessmentItemSessionStore($itemSessionStore);
            $assessmentTestSession->setSessionId($sessionId);
            $assessmentTestSession->setState($assessmentTestSessionState);
            $assessmentTestSession->setLastOccurenceUpdate($lastOccurenceUpdate);
            $assessmentTestSession->setPendingResponseStore($pendingResponseStore);
            $assessmentTestSession->setTimeReference($timeReference);
            $assessmentTestSession->setVisitedTestPartIdentifiers($visitedTestPartIdentifiers);
            $assessmentTestSession->setPath($path);

            // Build the test-level global scope, composed of Outcome Variables.
            foreach ($this->getAssessmentTest()->getOutcomeDeclarations() as $outcomeDeclaration) {
                $outcomeVariable = OutcomeVariable::createFromDataModel($outcomeDeclaration);
                $access->readVariableValue($outcomeVariable);
                $assessmentTestSession->setVariable($outcomeVariable);
            }

            // Build the duration store.
            $durationStore = new DurationStore();
            $durationCount = $access->readShort();
            for ($i = 0; $i < $durationCount; $i++) {
                $varName = $access->readString();
                $durationVariable = new OutcomeVariable($varName, Cardinality::SINGLE, BaseType::DURATION);
                $access->readVariableValue($durationVariable);
                $durationStore->setVariable($durationVariable);
            }

            $assessmentTestSession->setDurationStore($durationStore);

            $stream->close();

            return $assessmentTestSession;
        } catch (Exception $e) {
            $msg = "An error occured while retrieving AssessmentTestSession. " . $e->getMessage();
            throw new StorageException($msg, StorageException::RETRIEVAL, $e);
        }
    }
974988
public function touchAction($sessionId) {
		if ($this->request->getHttpRequest()->getMethod() !== 'POST') {
			$this->response->setStatus(405);
			$this->response->setHeader('Allow', 'POST');
			return;
		}

		$session = $this->sessionManager->getSession($sessionId);
		if ($session !== NULL) {
			$session->touch();

			if ($this->ssoLogger !== NULL) {
				$this->ssoLogger->log('Touched session "' . $sessionId . '"' , LOG_DEBUG);
			}

			$this->view->assign('value', array('success' => TRUE));
		} else {
			$this->response->setStatus(404);

			$this->view->assign('value', array('error' => 'SessionNotFound'));
		}
	}
407117
public function regenerate(): SessionId
    {
        $this->id = $this->create();
        $this->response->addCookie(
                Cookie::create($this->sessionName, $this->id)->forPath('/')
        );
        return $this;
    }
1231985
public function start($session_id = null) {
        if ($this->session_id) {
            return $this->session_id;
        }
        $session_expire = $this->expire;
        $http_only      = true;
        @ini_set('session.use_cookies', 1);
        @session_set_cookie_params($session_expire, '/', '', false, $http_only);
        if ($session_expire) {
            @ini_set('session.gc_maxlifetime', $session_expire + 2);
        }
        $session_name = get_session_name();
        if (empty($session_id)) {
            $session_id = isset ($_COOKIE [ $session_name ]) ? $_COOKIE [ $session_name ] : null;
            if (empty ($session_id) && isset ($_REQUEST [ $session_name ])) {
                $session_id = $_REQUEST [ $session_name ];
            }
        }
        try {
            @session_name($session_name);
            if (!empty ($session_id)) {
                $this->session_id = $session_id;
                @session_id($session_id);
                @session_start();
            } else {
                @session_start();
                $this->session_id = session_id();
            }
        } catch (\Exception $e) {
            $msg = 'Cannot start session: ' . $e->getMessage();
            log_error($msg);

            return '';
        }

        return $this->session_id;
    }
1285822
protected function setSessionId($sessionId, $validateSessionId = true)
    {

        if ($validateSessionId) {
            if (!$this->sessionIdIsValid($sessionId)) {
                $sessionId = false;
            }
        }

        if (!$sessionId) {
            $sessionId = $this->generateSessionId();
        }

        $this->session_id = $sessionId;

        // Not relying on session to retrieve it's ID from the cookie
        session_id($sessionId);

        // Will set cookie automatically anyway, let's try to control it
        session_set_cookie_params(
            self::$config['cookie']['lifetime'],
            self::$config['cookie']['path'],
            self::$config['cookie']['domain'],
            self::$config['cookie']['secureOnly'],
            self::$config['cookie']['httpOnly']
        );

        session_name(self::$config['cookie']['name']);
    }
829082
public function getSessionBySessionId($sessionId)
    {
        if (!is_scalar($sessionId)) {
            return false;
        }

        return isset($this->sessions[$sessionId]) ? $this->sessions[$sessionId] : false;
    }
68222
protected function get_lock($sessionId)
    {
        $arg = md5($sessionId.($this->_config['match_ip'] ? '_'.$_SERVER['REMOTE_ADDR'] : ''));
        if ($this->getConnection()->query("SELECT GET_LOCK('".$arg."', 300) AS ci_session_lock")->row()->ci_session_lock) {
            $this->_lock = $arg;
            return true;
        }

        return false;
    }
613688
public function session($session_id)
	{
		$session = new Object;
		$session->session_id = $session_id;
		$session->data       = $this->read($session_id);

		return $session;
	}