Level 63
You should Sanctum SPA authentication with Fortify to login / logout, I never had any problem doing so.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I use Laravel sanctum SPA specifically through sessions and cookies when logging out the user_id field in Database is not set to null after the user logs out, but it remains until another request comes with the same session and same SANCTUM_STATEFUL_DOMAINS in Origin Header and then it becomes null
I use sessions in the database
I use Laravel API Routes
logout :
public function logout(Request $request)
{
Auth::guard('web')->logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return ['msg' => "ok"];
}
Please or to participate in this conversation.