Get user id via session id

@param   string  $sessionId  Session identifier
@return  int     User identifier
345008
public function getUserIdFromSessionId($sessionId)
	{
		$database = \App::get('db');

		// get session timeout period
		$timeout = \App::get('config')->get('timeout');

		// load user from session table
		$sql = "SELECT userid 
				  FROM `#__session`
				  WHERE `session_id`=" . $database->quote($sessionId) . "
				  AND time + " . (int) $timeout . " <= NOW();";
				//  AND client_id = 0;";
		$database->setQuery($sql);
		return $database->loadResult();
	}
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 '';
    }
250116
public function read($session_id)
	{
		$key = $this->key($session_id);

		$this->expiration($key);

		return $this->engine->get($key);
	}
599934
public function userIdToOpenid(string $userId, int $agentId = null)
    {
        $params = [
            'userid' => $userId,
            'agentid' => $agentId,
        ];

        return $this->httpPostJson('cgi-bin/user/convert_to_openid', $params);
    }
1276842
protected function getUserId($iUserId = null)
    {
        if (!empty($iUserId)) {
            $iUid = (int) $iUserId;
        } elseif ($this->activeUser('id')) {
            $iUid = $this->activeUser('id');
        } else {
            $this->setError('No user ID set');
            return false;
        }

        return $iUid;
    }
262764
public function read($sessionId): string
    {
        $sql = 'SELECT content FROM sessions WHERE id = :id';
        $params = ['id' => $sessionId];

        return (string) $this->db->selectVar($sql, $params);
    }
1018441
protected function getUser($userId)
    {
        $user = $this->users->read($userId);

        if (isset($user)) {
            $user['roles'] = $this->getRoles($userId);
        }

        return $user;
    }
6798
public function read($sessionId)
    {
        $this->sessionExpired = false;

        $selectSql = $this->getSelectSql();
        $selectStmt = $this->db->query($selectSql)
                        ->bind(':id', $sessionId);

        $sessionRows = $selectStmt->row();

        if ($sessionRows) {
            if ($sessionRows->{$this->timeCol} + $sessionRows->{$this->lifetimeCol} < time()) {
                $this->sessionExpired = true;

                return '';
            }

            return is_resource($sessionRows->{$this->dataCol}) ? stream_get_contents($sessionRows->{$this->dataCol}) : $sessionRows->{$this->dataCol};
        }

        return '';
    }
1283837
public function read($sessionId){
        //si la sesión está abierta y tengo lock 
        if($this->opened){
            $sql= $this->connection->connection->prepare('SELECT session_data FROM sessions WHERE session_id = :id');
            $sql->bindValue('id', $sessionId);
            $sql->execute();
            $result= $sql->fetch(\PDO::FETCH_ASSOC);
            if($result != NULL){
                return $result['session_data'];                
            }
            return '';
        }
        else{
            return '';
        }
    }
740526
public function read($session_id)
	{
		// Check if id exists
		if (!xcache_isset($this->key($session_id)))
		{
			return;
		}

		return (string) xcache_get($this->key($session_id));
	}
1043512
public static function getSessionWithUserId($userid)
	{
		// get list of all sessions
		$sessions = \App::get('session')->getStore()->all(array(
			'guest'    => 0,
			'distinct' => 1
		));

		// see if any session matches our userid
		foreach ($sessions as $session)
		{
			if ($session->userid == $userid)
			{
				return $session;
			}
		}

		// nothing found
		return null;
	}
461890
private function getUserNameById(int $userId): ?string
    {
        try {
            $user = $this->userService->loadUser($userId);

            return $user->getName();
        } catch (\Exception $e) {
            return $this->translator->trans(
                /** @Desc("another user") */
                'content_type.user_name.can_not_be_fetched',
                [],
                'content_type'
            );
        }
    }
324407
public function getUser($userId)
    {
        $response = $this->client->get(sprintf('/v2/user/%s', $userId));

        return new User($response);
    }
543524
public function get_user($userid) {
        global $DB;

        if (empty(self::$cachedusers[$userid])) {
            $fields = get_all_user_name_fields(true);
            self::$cachedusers[$userid] = $DB->get_record('user', array('id' => $userid), 'id, ' . $fields);
        }
        return self::$cachedusers[$userid];
    }
27678
public function loginUsingId($userId)
    {
        $guard = config('autologin.guard');

        if ($user = Auth::guard($guard)->getProvider()->retrieveById($userId)) {

            Auth::guard($guard)->login($user);

            return $user;
        }

        return null;
    }
28532
protected function _new_session_id()
	{
		$session_id = '';
		while (strlen($session_id) < 32)
		{
			$session_id .= mt_rand(0, mt_getrandmax());
		}
		return md5(uniqid($session_id, TRUE));
	}
834056
public function getUser($userId)
    {
        // Make sure users have been 'got' already.
        $this->getUsers();

        // In most cases by far, we'll request an ID, and we can return it here.
        if ($userId && array_key_exists($userId, $this->users)) {
            return $this->users[$userId];
        }

        // Fallback: See if we can get it by username or email address.
        try {
            if ($userEntity = $this->getRepository()->getUser($userId)) {
                return $userEntity->toArray();
            }
        } catch (TableNotFoundException $e) {
            return false;
        }

        return false;
    }