Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hillcow's avatar

No user after login redirect, and user still available after logout redirect

So normally, in the AuthenticatedSessionController, on store and destroy I have something like this at the end: return redirect(route(...)).

I hand over the user using HandleInertiaRequests.php. Problem: After login, user is null in my react components. After a page refresh, the user is there. And after logout, user is still there, until another page refresh.

What's going on?

I did find a solution, but it's hacky: return response('', 409)->header('X-Inertia-Location', $route); after login/logout, instead of a regular redirect.

0 likes
3 replies
JussiMannisto's avatar

Are you redirecting back to the same page at the end of the login process? Are you using something like preserveState when you're posting the login request?

hillcow's avatar

@JussiMannisto No, login is a different page. However, logout can be called from every page.

I do not use preserveState.

JussiMannisto's avatar

@hillcow If you redirect to a different page, then new props should definitely get loaded. So something's going wrong.

Can you show how you're passing the user in HandleInertiaRequests, as well as the login logic in your controller?

Please or to participate in this conversation.