问题
I am using laravel 5.2 auth system to manage users but i have to delete a specific session variable after user logged out from the site. but i dont know where to place the session destroy function to achieve this.
回答1:
Use Session::flush(); to delete all variable
And Session::forget('key'); for particular key.
Use any of these after Logout and before you redirect to some page which could look like as below
public function getLogout() {
auth()->logout();
return redirect()->route('index');
}
来源:https://stackoverflow.com/questions/36996825/how-to-clear-a-session-variable-once-the-user-logout-in-laravel-5-2-auth-system