Skip to content

Kirby 3.8.4

$user->login()

Logs the user in

$user->login(string $password, \Kirby\Session\Session|array|null $session = null): bool

Parameters

Name Type Default Description
$password * string
$session Kirby\Session\Session|array|null null Session options or session object to set the user in

Return type

bool

Parent class

Kirby\Cms\User

Example

// simple login form submission example
if($username = get('username') and $password = get('password')) {

  $user = $kirby->user($username);

  if($user and $user->login($password)) {
    // redirect to the homepage
    // or any other page
    go();
  } else {
    echo 'invalid username or password';
  }

}

// put the login form with username and
// password field down here.