繁体   English   中英

Laravel 5 注销或会话销毁

[英]Laravel 5 logout or session destroy

我在注销 laravel 5.1 应用程序时遇到问题 - 我认为问题在于会话没有被破坏。

我的问题几乎与以下相同:

Laravel 5 Auth 注销不会破坏会话

需要注意的是,我的解决方案是使用

session_unset();

而不是

Session::flush();

所以我注销 laravel 5.1 应用程序的工作解决方案是:

public function getLogout()
{
    \Auth::logout();
    session_unset();
    return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');

    //these attempts will not remove values from the session.....

    //session()->forget('db');
    //\Session::flush();


}

任何想法为什么\\Session::flush(); session()->forget('db'); 不工作?

你可以试试这个:

Auth::logout();
Session::flush();

如果它不起作用,请检查 Config->Session.php 中的"'driver' => 'file'""'domain' => null"部分。

试试这个代码

Auth::logout();

或者

session_unset();

或者

Session::flush();

试试这个代码

使用 Illuminate\\Support\\Facades\\Session;

public function logout()
{
    Auth::logout();
    Session::flush();
    return redirect('/login');
 }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM