Example #1
0
    public function read($session_id)
    {
        if (!empty($this->excp)) {
            return false;
        }
        try {
            $stmt = $this->pdo->prepare('
					SELECT
						  id AS id
						, ' . \sys\PDO::getJsDate('expires') . ' AS expires
						, data AS data
						, id_user AS id_user
					FROM sessions WHERE ((id = :id) AND (expires > CURRENT_TIMESTAMP)) FOR UPDATE
				');
            $stmt->execute(array(':id' => $session_id));
            $session = $stmt->fetch(\PDO::FETCH_ASSOC);
            if (!empty($session['id_user'])) {
                $this->user = $this->userService->getUser($session['id_user']);
                static::extendSessoinRole($this->user);
            }
            return !empty($session) ? $session['data'] : null;
        } catch (\PDOException $excp) {
            $this->excp = $excp;
        }
        return null;
    }