0

I'm currently setting an array of tokens in a user's session on a laravel site, and the session successfully sets the array (called tokenArray) which shows in the debug bar for the session as expected:

    if (!is_null($user) && $user->active) {

        Auth::login($user);

        Session::put('Tokens',$tokenArray);

        return redirect()->intended($this->redirectPath());

    }

The issue is that when I logout successfully and get redirected to the sign in page the array of tokens still shows in the session on the debug bar.

I would think it would be destroyed by default but is there a way that I need to flush the array specifically? I have a listener on the logout event, so if I need to I could try something there.

SHould this be cleared by default though?

2 Answers 2

1

Do a Session::flush(); on your logout method to delete all session data or.

Session::forget('tokens');

to delete only the tokens.

Sign up to request clarification or add additional context in comments.

Comments

1

You can also use session helper.

session()->forget('tokens');

To delete all session data call following method.

 session()->flush();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.