Redirect to a page after logging out in Laravel

In Laravel normally logout function enables user to logout from the session and remain on the login page or index page. The default function for logout in Laravel is given below.

public function logout(Request $request)

{

$this->guard()->logout();

$request->session()->flush();


$request->session()->regenerate();


return redirect('/');

}

To redirect to a particular page on logout make the following change in the Auth\LoginController:

use AuthenticatesUsers {

logout as performLogout;

}

Then in the return redirect add your route in the LoginController’s logout() method.

public function logout(Request $request)

{

$this->performLogout($request);

return redirect()->route('your_route');

}

For Laravel 5.7 and above you can simply override the logout method.

//App\Http\Controllers\Auth\LoginController.php

protected function loggedOut(Request $request) {

return redirect('/where/ever/you/want/to/go');

}