【问题标题】:Laravel User LogoutLaravel 用户注销
【发布时间】:2016-02-13 05:53:36
【问题描述】:

您好,我尝试实现注销。我还在 users 表中添加了 remember_token 。当我登录时它会更新,但我无法使用以下功能注销。我需要添加更多内容才能退出吗?

public function doLogout(){
  Auth::logout();
  Session::forget('user');
  return Redirect::to('/#signin');
}

【问题讨论】:

  • 这应该可以解决问题。它显示的错误是什么?
  • 我没有收到任何错误。我使用 Auth::check() 在我注销后检查用户是否登录。我对这个值是正确的

标签: php authentication logging laravel-5.1


【解决方案1】:

试试这个,先创建一条路线

Route::get('auth/logout', ['as' => 'auth.logout', 'uses' => 'Auth\AuthController@getLogout']);

然后添加一个链接,

<a href="{{ route('auth.logout') }}">Logout</a>

或重定向。

public function doLogout(){
    return redirect()->route('auth.logout');
}

您可以查看此文档以获取更多信息 http://laravel.com/docs/master/authentication#included-authenticating

【讨论】:

    猜你喜欢
    • 2014-08-08
    • 2016-08-22
    • 2017-11-08
    • 2015-06-23
    • 2016-08-14
    • 2022-10-15
    • 1970-01-01
    • 2020-09-03
    • 2018-06-07
    相关资源
    最近更新 更多