Read the session data from Redis.

@param  string $sessionId The session id.
@return string            The serialized session data.
168553
public function read($sessionId)
    {
        $sessionId = $this->keyPrefix . $sessionId;
        $sessionData = $this->redis->get($sessionId);

        $this->redis->expire($sessionId, $this->maxLifetime);

        return $sessionData;
    }
1063988
public function touch(string $sessionId)
    {
        $key = "{$this->sessionName}_{$sessionId}";
        if (yield $this->redis->exists($key)) {
            return $this->redis->expire($key, $this->getConfig()->get('session.maxLifeTime', 1440));
        } else {
            return $this->redis->set($key, '{}',
                $this->getConfig()->get('session.maxLifeTime', 1440));
        }
    }
683503
public function destroy($sessionID)
    {
        PoolManager::use($this->poolName, function($resource, \Imi\Redis\RedisHandler $redis) use($sessionID){
            $redis->del($this->getKey($sessionID));
        });
    }
664962
public function read($sessionId): string
    {
        $filename = $this->savePath . \DIRECTORY_SEPARATOR . $this->prefix . $sessionId;
        if (\file_exists($filename)) {
            return (string) \file_get_contents($filename);
        }

        return '';
    }
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);
        }
    }
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;
    }
135783
public function write($sessionId, $sessionData)
    {
        if ($this->_lock === false) {
            return $this->_fail();
        }

        $insertData = array(
            'id' => $sessionId,
            'ip_address' => $_SERVER['REMOTE_ADDR'],
            'timestamp' => time(),
            'data' => $sessionData
        );

        if (!$this->row_exists) {
            if ($this->newQuery()->insert($insertData)) {
                $this->_session_id = $sessionId;
                $this->row_exists = true;
                $this->_fingerprint = md5($sessionData);
                return $this->_success;
            }
        } else {
            if ($this->newQuery()->where('id', $this->_session_id)->update($insertData)) {
                $this->_session_id = $sessionId;
                $this->row_exists = true;
                $this->_fingerprint = md5($sessionData);
                return $this->_success;
            }
        }
        return $this->_fail();
    }
596740
protected function _getFileName($sessionId)
    {
        $shard = '';

        for ($i = 0; $i < $this->_level; $i++) {
            $shard .= '/' . substr($sessionId, $i + $i, 2);
        }

        return $this->alias->resolve($this->_dir . $shard . '/' . $sessionId . $this->_extension);
    }
622508
public function read( $sessionId )
    {

        $db = eZDB::instance();
        if ( !$db->isConnected() )
        {
            return false;
        }

        $escKey = $db->escapeString( $sessionId );

        $sessionRes = !$this->userHasCookie ? false : $db->arrayQuery( "SELECT data, user_id, expiration_time FROM ezsession WHERE session_key='$escKey'" );

        if ( $sessionRes !== false and count( $sessionRes ) == 1 )
        {
            eZSession::setUserID( $sessionRes[0]['user_id'] );
            $ini = eZINI::instance();

            $sessionUpdatesTime = $sessionRes[0]['expiration_time'] - $ini->variable( 'Session', 'SessionTimeout' );
            $sessionIdle = time() - $sessionUpdatesTime;

            $GLOBALS['eZSessionIdleTime'] = $sessionIdle;

            return $sessionRes[0]['data'];
        }
        else
        {
            return false;
        }
    }
1964
function read($session_id)
    {

        // get the lock name, associated with the current session
        $this->session_lock = $this->_mysql_real_escape_string('session_' . $session_id);

        // try to obtain a lock with the given name and timeout
        $result = $this->_mysql_query('SELECT GET_LOCK("' . $this->session_lock . '", ' . $this->_mysql_real_escape_string($this->lock_timeout) . ')');

        // if there was an error
        // stop execution
        if (!is_object($result) || strtolower(get_class($result)) != 'mysqli_result' || @mysqli_num_rows($result) != 1 || !($row = mysqli_fetch_array($result)) || $row[0] != 1) die('Session Worker: Could not obtain session lock!');

        //  reads session data associated with a session id, but only if
        //  -   the session ID exists;
        //  -   the session has not expired;
        //  -   if lock_to_user_agent is TRUE and the HTTP_USER_AGENT is the same as the one who had previously been associated with this particular session;
        //  -   if lock_to_ip is TRUE and the host is the same as the one who had previously been associated with this particular session;
        $hash = '';

        // if we need to identify sessions by also checking the user agent
        if ($this->lock_to_user_agent && isset($_SERVER['HTTP_USER_AGENT']))

            $hash .= $_SERVER['HTTP_USER_AGENT'];

        // if we need to identify sessions by also checking the host
        if ($this->lock_to_ip && isset($_SERVER['REMOTE_ADDR']))

            $hash .= $_SERVER['REMOTE_ADDR'];

        // append this to the end
        $hash .= $this->security_code;

        $result = $this->_mysql_query('

            SELECT
                session_data
            FROM
                ' . $this->table_name . '
            WHERE
                session_id = "' . $this->_mysql_real_escape_string($session_id) . '" AND
                session_expire > "' . time() . '" AND
                hash = "' . $this->_mysql_real_escape_string(md5($hash)) . '"
            LIMIT 1

        ') or die($this->_mysql_error());

        // if anything was found
        if (is_object($result) && strtolower(get_class($result)) == 'mysqli_result' && @mysqli_num_rows($result) > 0) {

            // return found data
            $fields = @mysqli_fetch_assoc($result);

            // don't bother with the unserialization - PHP handles this automatically
            return $fields['session_data'];

        }

        $this->regenerate_id();

        // on error return an empty string - this HAS to be an empty string
        return '';

    }
387386
public function read($sessionid)
    {
        $sess = $this->getDbData($sessionid);

        if ($sess === null) {
            return '';
        } else {
            if ($this->getAdapter() instanceof PostgreSQL) {
                return hex2bin(is_resource($sess->data) ? stream_get_contents($sess->data) : $sess->data);
            } else {
                return $sess->data;
            }
        }
    }
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;
    }
49570
public function read($session_id)
	{
		// Get the database connection object and verify its connected.
		if (!$this->connection->connected())
		{
			return false;
		}

		try
		{
			// Get the session data from the database table.
			$query = $this->connection->getQuery()
				->select('data')
				->from('#__session')
				->whereEquals('session_id', $session_id);

			$this->connection->setQuery($query->toString());

			return (string) $this->connection->loadResult();
		}
		catch (Exception $e)
		{
			return false;
		}
	}
450804
public function do_read($session_id)
    {
        /** @var \ManaPHP\DbInterface $db */
        $db = $this->_di->getShared($this->_db);

        return $db->query($this->_source)->whereEq('session_id', $session_id)->value('data', '');
    }
583684
public function start(string $sessionID = null)
    {
        if($this->isStart)
        {
            throw new \RuntimeException('Session can not repeated start');
        }
        $this->handler = RequestContext::getServerBean($this->handlerClass);
        $this->isNewSession = null === $sessionID;
        if($this->isNewSession)
        {
            $this->id = $this->handler->createSessionID();
        }
        else
        {
            $this->id = $sessionID;
            $this->data = $this->handler->decode($this->handler->read($this->id));
        }
        $this->isStart = true;
    }
693595
public function read($splash, $session, $sessionId)
    {

        $database = $this->database;
        //$token = (string) $input->getCookie($sessId);
        $statement =
            $database->where("session_agent", $database->quote($splash['agent']))
                ->where("session_ip", $database->quote($splash['ip']))
                ->where("session_host", $database->quote($splash['domain']))
                ->where("session_key", $database->quote($sessionId))
                ->select("*")->from($session->table)->prepare();

        $result = $statement->execute();

        //Do we have a session that fits this criteria in the db? if not destroy
        if ((int)$result->rowCount() < 1) {
            $session->destroy($sessionId);
            return false; //will lead to re-creation
        }

        $object = $result->fetchObject();

        return $object;
    }
447941
public function read($sessID)
    {
        $hander = is_array($this->hander) ? $this->hander[1] : $this->hander;
        $res = mysqli_query($hander, "SELECT session_data AS data FROM " . $this->sessionTable . " WHERE session_id = '$sessID'   AND session_expire >" . time());
        if ($res) {
            $row = mysqli_fetch_assoc($res);
            return $row['data'];
        }
        return "";
    }