auth login laravel user code example

Example 1: how login one user with id in laravel

public function manualLogin(){
    $user = User::find(1);
    Auth::login($user);
    return redirect('/');
}
///////////////////////////////////////////////////////////////
// or 

Auth::logout();

Example 2: laravel auth user_id

$userId = Auth::id();

Example 3: laravel auth

composer require laravel/ui

php artisan ui vue --auth

npm install && npm run dev

Example 4: auth::login in laravel

public function manualLogin(){
    $user = User::find(1);
    Auth::login($user);
    return redirect('/');
}


or 
  
  
  Auth::logout();

Tags:

Php Example