Skip to content

Kirby 4.5.0

$user->loginPasswordless()

Logs the user in without checking the password

$user->loginPasswordless(Kirby\Session\Session|array|null $session = null): void

Parameters

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

Parent class

Kirby\Cms\User

Example

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

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

  if($user) {
    // verify access with a different method like
    // OAuth, IndieAuth, email or SMS token etc.
    myCustomAuthProvider();

    // now that that succeeded, log the user in without checking the provided password
    // NOTE: Only use this if you have verified access in other ways like in this example!
    $user->loginPasswordless();

    // redirect to the homepage
    // or any other page
    go();
  } else {
    echo 'login process failed';
  }

}