Read user record from session.

@return array|null User record if available else null.
345088
public function read()
    {
        if ($this->_user !== null) {
            return $this->_user ?: null;
        }

        $this->_user = $this->_session->read($this->_config['key']) ?: false;

        return $this->_user ?: null;
    }
1306890
public function getUsername() {
		if (isset($_SESSION) && isset($_SESSION[self::SESSION_FIELD_USERNAME])) {
			return $_SESSION[self::SESSION_FIELD_USERNAME];
		}
		else {
			return null;
		}
	}
657978
public function &user($user = null)
    {
        if($user) {
            $_SESSION[$this->params['session_key']] = $user;
        }
        else {
            if(!$this->check()) {
                throw new UserException('Not logged in', 403);
            }
        }


        return $_SESSION[$this->params['session_key']];
    }
906670
private function getCurrentUser()
    {
        if (is_object($token = $this->get('security.token_storage')->getToken()) and is_object($user = $token->getUser())) {
            return $user;
        }
    }
468251
public function current() {
        $user = \core_user::get_user($this->userids[$this->iteratorposition]);

        if (false === $user) {
            // This user was not found.
            unset($this->userids[$this->iteratorposition]);

            // Check to see if there are any more users left.
            if ($this->count()) {
                // Move the pointer to the next record and try again.
                $this->next();
                $user = $this->current();
            } else {
                // There are no more context ids left.
                return;
            }
        }

        return $user;
    }
949769
protected function getUserId()
    {
        if (property_exists($this, 'userKey'))
        {
            $userKey = $this->userKey;

            return $this->$userKey;
        }

        if ( ! is_null($this->user_id))
        {
            return $this->user_id;
        }

        return null;
    }
800223
public function userId()
	{
		if (isset($this->user_id)) {
			return $this->user_id ? $this->user_id : null;
		}
		
		$this->check();
		$this->user_id = false;
		
		if ('user' == $this->type) {
			if ($user_id = Authorizer::getResourceOwnerId()) {
				return $this->user_id = $user_id;
			}
		}
		
		return null;
	}
40488
private function read()
    {
        if ($this->request->hasParam($this->sessionName)) {
            return $this->request->readParam($this->sessionName)->ifMatches(self::SESSION_ID_REGEX);
        } elseif ($this->request->hasCookie($this->sessionName)) {
            return $this->request->readCookie($this->sessionName)->ifMatches(self::SESSION_ID_REGEX);
        }

        return null;
    }
1137350
public function getCurrentUser()
    {
        if ($this->currentuser === null) {
            $this->currentuser = $this->app['session']->isStarted() ? $this->app['session']->get('authentication') : null;
            if ($this->currentuser instanceof AccessControl\Token\Token) {
                $this->currentuser = $this->currentuser->getUser()->toArray();
            }
        }

        return $this->currentuser;
    }
1221468
public function getSettingsRecord()
    {
        $item = UserPreference::forUser();
        $record = $item
            ->scopeApplyKeyAndUser($this->model, $this->recordCode, $item->userContext)
            ->remember(1440, $this->getCacheKey())
            ->first();

        return $record ?: null;
    }
425059
public static function user()
    {
        if (self::check()) {
            if (is_null(static::$user)) {
                $data = Session::get(static::resource('session'));

                $data = static::query($data);

                static::$user = static::orm($data[0]);
            }

            return static::$user;
        }
    }
443436
public function getUserId()
	{
		if ($this->session_machine === null) {
			throw new RuntimeException('Session machine not ready ‒ '.__METHOD__.' called too soon.');
		}
		return $this->session_machine->state !== '' ? $this->session_machine[$this->user_id_property] : null;
	}
462063
public function user()
    {
        // if the user was explicitly marked as logged out.
        if ($this->loggedOut) {
            // just return null.
            return null;
        }

        // if the user is already set.
        if ($this->user) {
            return $this->user;
        }

        // detects a token presence.
        $token = $this->detectedToken();

        // if the received token is not actually valid.
        if (!$token || !$this->manager->validToken($token)) {
            // also return null since the token
            // signature could not be determined.
            return null;
        }

        // if the token has expired.
        if ($this->manager->expired($token)) {
            // you got right?
            return null;
        }

        // try to find the user which the token belongs to.
        $user = $this->findUserByToken($token);

        // if the user has not been found.
        if (!$user) {
            // abort!
            return null;
        }

        // set the current user on the scope.
        $this->setUser($user);

        // return the scope user.
        return $this->user;
    }
1225373
public function read($id)
    {
        $items = [];
        $items = $this->select('data')->where('session_id', '=', $id)
            ->limit('1')
            ->findAll('assoc');

        return isset($items[0]['data']) ? @$items[0]['data'] : null;
    }
1074306
public function getUsersPairs()
    {
        // Check and init cache
        if (!self::$cached_users_pairs) {
            $user_collection = new AdminUserRepository;
            $user_collection->addOrderByField('name');
            foreach ($user_collection->getAsArrayOfObjects() as $v) {
                /** @var AdminUser $v */
                self::$cached_users_pairs[$v->getId()] = $v->getName() . ' ' . $v->getSurname() . ' [' . $v->getLogin() . ']';
            }
        }

        return self::$cached_users_pairs;
    }
132010
protected function store_get_user_status() {
		$this->init();
		if ($this->user_token === null)
			return null;
		if ($this->user_data !== null)
			return $this->user_data;

		$token = $this->user_token;

		# cache validation
		$cached = $this->store_redis_cache_read($token);
		if ($cached !== null) {
			if ($cached['uid'] == -1)
				# cached invalid session
				return null;
			# cached valid session
			return $this->user_data = $cached;
		}

		$expire = $this->store->stmt_fragment('datetime');
		$session = $this->store->query(
			sprintf(
				"SELECT * FROM v_usess " .
				"WHERE token=? AND expire>%s " .
				"LIMIT 1",
				$expire
			), [$token]);
		if (!$session) {
			# session not found or expired
			$this->store_reset_status();
			# cache invalid session for 10 minutes
			$this->store_redis_cache_write($token,
				['uid' => -1], null, 600);
			return $this->user_data;
		}

		if (!$this->redis)
			return $this->user_data = $session;

		$this->store_redis_cache_write($token, $session,
			$session['expire']);

		return $this->user_data = $session;
	}
958445
public function getFromSession()
    {
        $sessionInfo = $this->getCurrentSessionData();

        if (is_array($sessionInfo)) {
            if (isset($sessionInfo['id']) && !empty($sessionInfo['id'])) {
                $recordId = intval($sessionInfo['id']);

                return $this->findOne($recordId);
            }
        }

        return false;
    }