Summer Sale! All accounts are 50% off this week.

Cushty's avatar
Level 4

User switching randomly to different user in Inertia

Hi, I have a very strange bug where I log in with one user , click around, log out of that user, login with another user click around and on the settings page im literally another user. i can press the back and forward buttons on chrome and see the 2 users emails addresses in settings.

I did some testing in Tinker and when the bug happens, it seem like im getting logged out and logged in with another user.

Have you ever encountered this?

React, Inertia, Hope you can help, thanks

0 likes
5 replies
ryangurnick's avatar

Can you share some of the code related to your settings page?

I suspect that there is some amount of caching causing issues but its quite hard to know for sure from a description of a problem without code.

Cushty's avatar
Level 4

@ryangurnick

It's so strange, I can literally see the other user, if I hard refresh it goes away and i see the logged in users details. Hope you can help, at a total loss

jlrdw's avatar

Are you correctly logging out, something like this:

    public function logout(Request $request)
    {
        Auth::logout();

        $request->session()->invalidate();

        $request->session()->regenerateToken();

        return redirect('/');
    }
Cushty's avatar
Level 4

@jlrdw Im using the default logging out supplied by Laravel React starter kit, I havnt touched that file.

martinbean's avatar

@cushty How is your application hosted? Is it behind a load balancer or something?

1 like

Please or to participate in this conversation.