Laravel database session's table user_id is always null

1 week ago 13
ARTICLE AD BOX

I'm using Laravel version 12 and now I'm facing a problem when I try to login with correct username and password (they had been seeded to database) it redirected me to login page and not dashboard page. When I changed the session_driver to file it worked out yet it didn't change it back to database. It also said auth_check is false.

public function doLogin(UserLoginWebRequest $request): Response | RedirectResponse{ $data = $request->only('username', 'password'); if(!Auth::guard('web')->attempt($data)){ return back()->withErrors(['errors' => 'Username atau password salah'])->onlyInput('username'); } $request->session()->regenerate(); return redirect()->intended('/'); }

Here's the lists of routes

Route::get('/', [HomeController::class, 'home']); Route::middleware('guest')->group(function (){ Route::get('/login', [AuthWebController::class, 'showLogin'])->name('login'); Route::post('/login', [AuthWebController::class, 'doLogin'])->name('login.post'); }); Route::middleware('auth:web')->post('/logout', [AuthWebController::class, 'doLogout']); Route::middleware('auth:web')->get('/dashboard', [UserWebController::class, 'index']);
Read Entire Article