一旦用户在laravel 5.2 auth系统中注销,如何清除会话变量 [英] How to clear a session variable once the user logout in laravel 5.2 auth system

查看:282
本文介绍了一旦用户在laravel 5.2 auth系统中注销,如何清除会话变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用laravel 5.2身份验证系统来管理用户,但是在用户从站点注销后,我必须删除特定的会话变量.但我不知道将会话销毁功能放在何处以实现此目的.

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.

推荐答案

使用Session::flush();删除所有变量

Session::forget('key');表示特定的键.

Logout之后且重定向到某个如下所示的页面之前,请使用其中的任何一个

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');
}

这篇关于一旦用户在laravel 5.2 auth系统中注销,如何清除会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆