Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ekaitzastiz's avatar

Can't logout, can't close session

I am working with L5.2, I try to logout, but it doesn't work, it's returning to the same page, it seems like a loop, it returs to /login, but is authenticated so it returs to the page. It never closes the session. I clean cookies, sessions... in my browser and then it works, I mean, it's logged out... Any idea?

0 likes
2 replies
ekaitzastiz's avatar

Ok, now I moved the "web" middleware from admin routes group, it seems to work, but now something strange is happening, wome routes do not work..., I am not sure if I am using middleware in the correct way...

I have

Route::get('login',['middleware' => ['web'],'as'=>'auth.getLogin','uses'=> 'Auth\AuthController@getLogin']);
Route::post('login',['middleware' => ['web'],'as'=>'auth.postLogin','uses'=> 'Auth\AuthController@postLogin']);
Route::get('logout', ['middleware' => ['web'],'prefix'=>'admin','as' => 'auth.logout', 'uses' => 'Auth\AuthController@getLogout']);

Route::group(['middleware' => ['web','auth'],'prefix'=>'admin','namespace'=>'Admin'], function () {
});
ekaitzastiz's avatar
ekaitzastiz
OP
Best Answer
Level 9

I had duplicated middleware... in controller and in the route, that was making some strange things...

1 like

Please or to participate in this conversation.