public function login(string $userName, string $password, string $storedUserName = '', string $storedPassword = '', int $storedId): bool
    {
        if ($userName === $storedUserName && $this->password->verify($password, $storedPassword)) {
            //write valid login on session
            $this->session->loginTime = \time();
            $this->session->login = [
                'login'     => true,
                'user_id'   => $storedId,
                'user_name' => $storedUserName,
            ];

            //update login data
            $this->data = $this->session->login;

            //regenerate session id
            $this->session->regenerate();
            $this->logged = true;

            return true;
        }

        return false;
    }
public function login(string $userName, string $password, string $storedUserName = '', string $storedPassword = '', int $storedId): bool
    {
        if ($userName === $storedUserName && $this->password->verify($password, $storedPassword)) {
            //write valid login on session
            $this->session->loginTime = \time();
            $this->session->login = [
                'login'     => true,
                'user_id'   => $storedId,
                'user_name' => $storedUserName,
            ];

            //update login data
            $this->data = $this->session->login;

            //regenerate session id
            $this->session->regenerate();
            $this->logged = true;

            return true;
        }

        return false;
    }
public function login ( string $ userName , string $ password , string $ storedUserName = '' , string $ storedPassword = '' , int $ storedId ) : bool { if ( $ userName === $ storedUserName && $ this -> password -> verify ( $ password , $ storedPassword ) ) { //write valid login on session $ this -> session -> loginTime = \ time ( ) ; $ this -> session -> login = [ 'login' => true , 'user_id' => $ storedId , 'user_name' => $ storedUserName , ] ; //update login data $ this -> data = $ this -> session -> login ; //regenerate session id $ this -> session -> regenerate ( ) ; $ this -> logged = true ; return true ; } return false ; }
Try to attemp login with the informations passed by param.

<pre><code class="php">$user = ''; //user from login page form
$password = ''; //password from login page form

$storedUser = ''; //user from stored informations
$storedPassword = ''; //password hash from stored informations
$storedId = ''; //user id from stored informations

$auth = new Authentication($session, $password);
$auth->login($user, $password, $storedUser, $storedPassword, $storedId);

//other operation after login
</code></pre>

@param string $userName       User name from browser input.
@param string $password       Password from browser input.
@param string $storedUserName User name from persistent storage.
@param string $storedPassword Password from persistent storage.
@param int    $storedId       User id from persistent storage.

@return bool True for successful login, false if login fails.
Try to attemp login with the informations passed by param .