解決Laravel5.2 Auth認(rèn)證退出失效的問題
登錄正常,但是退出的時(shí)候并沒有清掉session,退出后還是處于登錄狀態(tài)。解決方法如下:
路由如下
Route::group(['namespace' => 'Admin', 'middleware' => 'auth'], function() { Route::resource('admin/post', 'PostController'); }); // 登陸 Route::get('auth/login', 'Auth\AuthController@getLogin'); Route::post('auth/login', 'Auth\AuthController@postLogin'); // 5.2版本這里的方法需要寫成logout,因?yàn)樵谥虚g件中是這么定義的 public function __construct() { $this->middleware($this->guestMiddleware(), ['except' => 'logout']); } // 路由中的方法要跟上述一致 Route::get('auth/logout', 'Auth\AuthController@logout');
AuthController.php中的
// 登錄成功后跳轉(zhuǎn)地址 protected $redirectTo = 'admin/post'; // 退出后跳轉(zhuǎn)地址 protected $redirectAfterLogout = 'auth/login';
參考 http://stackoverflow.com/questions/34479994/laravel-5-2-authlogout-is-not-working
調(diào)試過程中在AppserviceProvider的boot方法里添加輸出sql也會導(dǎo)致類似的錯(cuò)誤,所以在登錄調(diào)試時(shí),盡量不要這樣做
/** * Bootstrap any application services. * * @return void */ public function boot() { // \DB::listen(function($sql) { // dump($sql->sql); // }); }
以上這篇解決Laravel5.2 Auth認(rèn)證退出失效的問題就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
- Laravel 默認(rèn)郵箱登錄改成用戶名登錄的實(shí)現(xiàn)方法
- laravel5.4利用163郵箱發(fā)送郵件的步驟詳解
- 在Laravel框架里實(shí)現(xiàn)發(fā)送郵件實(shí)例(郵箱驗(yàn)證)
- Laravel 5框架學(xué)習(xí)之用戶認(rèn)證
- 詳解Laravel5.6 Passport實(shí)現(xiàn)Api接口認(rèn)證
- Laravel5.5中利用Passport實(shí)現(xiàn)Auth認(rèn)證的方法
- Laravel實(shí)現(xiàn)用戶多字段認(rèn)證的解決方法
- Laravel認(rèn)證原理以及完全自定義認(rèn)證詳解
- Laravel多用戶認(rèn)證系統(tǒng)示例詳解
- laravel實(shí)現(xiàn)Auth認(rèn)證,登錄、注冊后的頁面回跳方法
- laravel框架郵箱認(rèn)證實(shí)現(xiàn)方法詳解
相關(guān)文章
PHP網(wǎng)頁游戲?qū)W習(xí)之Xnova(ogame)源碼解讀(十六)
這篇文章主要介紹了PHP網(wǎng)頁游戲Xnova(ogame)源碼解讀的攻擊任務(wù)頁面的代碼流程,需要的朋友可以參考下2014-06-06laravel框架上傳圖片實(shí)現(xiàn)實(shí)時(shí)預(yù)覽功能
今天小編就為大家分享一篇laravel框架上傳圖片實(shí)現(xiàn)實(shí)時(shí)預(yù)覽功能,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-10-10php 提速工具eAccelerator 配置參數(shù)詳解
php 提速工具eAccelerator 配置參數(shù)詳解,需要的朋友可以參考下。2010-05-05php和redis實(shí)現(xiàn)秒殺活動(dòng)的流程
這篇文章主要介紹了php和redis設(shè)計(jì)秒殺活動(dòng)的流程,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-07-07PHP 實(shí)現(xiàn)從數(shù)據(jù)庫導(dǎo)出到.csv文件方法
這篇文章主要介紹了 PHP 實(shí)現(xiàn)從數(shù)據(jù)庫導(dǎo)出到.csv文件方法的相關(guān)資料,需要的朋友可以參考下2017-07-07