Reputation: 5107
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?
Upvotes: 0
Views: 53
Reputation: 518
You can also use session helper.
session()->forget('tokens');
To delete all session data call following method.
session()->flush();
Upvotes: 1
Reputation: 2621
Do a Session::flush();
on your logout method to delete all session data or.
Session::forget('tokens');
to delete only the tokens.
Upvotes: 1