Performance: Login and logout
MEDIUM IMPACT
This affects page load speed and interaction responsiveness during user authentication processes.
<?php
use Illuminate\Support\Facades\Auth;
public function login(Request $request) {
if (Auth::attempt($request->only('email', 'password'))) {
$request->session()->regenerate();
return redirect()->intended('/dashboard');
}
return back()->withErrors(['email' => 'Invalid credentials']);
}<?php
// In Controller
public function login(Request $request) {
$user = User::where('email', $request->email)->first();
if ($user && Hash::check($request->password, $user->password)) {
session(['user' => $user]);
return redirect('/dashboard');
}
return back()->withErrors(['email' => 'Invalid credentials']);
}| Pattern | Server Processing | Session Handling | Response Time | Verdict |
|---|---|---|---|---|
| Manual session management | High (custom code) | Full session flush | Slower (~100ms delay) | [X] Bad |
| Laravel Auth methods | Optimized (built-in) | Targeted session invalidate | Faster (~50ms faster) | [OK] Good |