【问题标题】:Laravel 5 logout or session destroyLaravel 5 注销或会话销毁
【发布时间】:2016-03-21 10:08:59
【问题描述】:

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

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

Laravel 5 Auth Logout not destroying session

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

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'); 不起作用?

【问题讨论】:

    标签: php laravel


    【解决方案1】:

    试试这个代码

    使用 Illuminate\Support\Facades\Session;

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

    【讨论】:

    • 另一个没有带来任何结果的答案,因为这些都在问题的代码中
    【解决方案2】:

    试试这个代码

    Auth::logout();
    

    session_unset();
    

    Session::flush();
    

    【讨论】:

    • 这个答案增加了什么?这正是 op 所做的。
    【解决方案3】:

    你可以试试这个:

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

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

    【讨论】:

    • 会话::flush();不起作用。 session_unset();确实有效。驱动程序设置为文件,域设置为空。我想知道是不是我的开发环境让我设置了一个不同的开发环境。
    • 我将在这个星期六通过 Skype 为您提供帮助。你能在 Skype 上加我吗:alierdemsunar。
    猜你喜欢
    • 2016-11-04
    • 1970-01-01
    • 1970-01-01
    • 2014-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-30
    相关资源
    最近更新 更多