Authentication in PHP
From the Laravel cheat sheet · Authentication & Authorization · verified Jul 2026
Authentication
User authentication with Laravel
php
// Check authentication
if (Auth::check()) {
// User is logged in
}
// Get authenticated user
$user = Auth::user();
$user = auth()->user();
$user = $request->user();
// Login
Auth::login($user);
Auth::loginUsingId(1);
// Logout
Auth::logout();💡 Use Laravel Breeze for simple authentication scaffolding
⚡ Always regenerate session after login for security
📌 Use guards for multiple authentication systems
🔥 Remember to hash passwords with Hash::make()