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

Crazylife's avatar

How to clear sessionstorage item when user logout?

In my controller, how do i clear the sessionStorage item?

public function logout()
    {
        Auth::logout();
        Session::flush();
        return redirect('/login');
    }

I stored some data inside session storage and i want to clear it after user logout. But it will only clear if the browser closed.

0 likes
2 replies
Manarjd's avatar

try sessionStorage.clear(); and call it only when the user log out.

Snapey's avatar

@Manarjd we are running javascript inside Laravel framework now are we?

And this question IS SIX YEARS OLD

1 like

Please or to participate in this conversation.