Use the network tools and see if the cookie is still there or not.
Are you using tokens or cookie based with fortify. I know you said cookie, but just checking.
re you using:
Auth::guard('web')->logout();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am experiencing an issue with Sanctum cookie authentication. When I log out and try to log in using a different user, I receive a 401 Unauthenticated response. However, if I attempt to log in again, it works. Logging out and logging in with the same user also works without any issues. Additionally, if I clear the site cookies and log in, everything works as expected. The problem only occurs when logging out and logging in with a different username.
Steps To Reproduce Log in with User A.
Log out.
Log in with User B.
Observe the 401 Unauthenticated response.
Attempt to log in again with User B.
Observe that the login is successful.
Expected Behavior: Logging out and logging in with a different user should work without any issues.
Actual Behavior: The first login attempt with a different user after logging out results in a 401 Unauthenticated response. Subsequent login attempts are successful.
@XiDanko do you have the remember me cookie setup? If so that might be an issue.
Also see https://github.com/laravel/sanctum/issues/87#issuecomment-2603720740
But read through the whole issue.
Seems that
Session::invalidate();
worked there.
Edit:
Also don't mix api and spa parts, which messed up one user, stick to the spa part of the sanctum documentation.
I suggest undoing all and then redo it using spa part.
Also if just testing, you can change setting in browser to delete all cookies on close, I use firefox.
Please or to participate in this conversation.