How to clear a session variable once the user logout in laravel 5.2 auth system

时光总嘲笑我的痴心妄想 提交于 2019-12-12 02:07:48

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!