Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the redirect url when logging out?

I'm working with Laravel 5 authentification system provided by default. After logging out, a user is redirected to the root page but I'd like to change that. I managed to do it for the "login" and "registering" process by defining "$redirectTo" in "AuthController.php". But for "logout", I defined "$redirectAfterLogout" at the same place but it seems to not be taken into account.

Could anyone explain me where is the problem and how to fix it please? Thanks a lot.

like image 321
kururin Avatar asked Apr 22 '15 12:04

kururin


People also ask

How do I redirect a page after logging out?

To redirect the user after they log out from a specific application, you must add the URL used in the returnTo parameter of the redirect URL to the Allowed Logout URLs list in the Settings tab of your Auth0 application that is associated with the CLIENT_ID parameter.

What is a logout URL?

The Logout Endpoint URL sends a logout request to OAuth provider to logout from the provider while logging out the user from the application. It is required that the OAuth provider supports logout requests.

How do I redirect a WordPress login page after logging out?

In your WordPress admin panel, go to Plugins > New Plugin, search for “WP Login and Logout Redirect” and click on “Install Now” Alternatively, download the plugin and upload the wordpress-login-and-logout-redirect. zip to your plugins directory, which usually is /wp-content/plugins/.

How do I redirect a user to login?

You can use session variable to do this, you ust be set session on login. So on edit page starting you can write following code to check wheter user is logged in or not.. your condition is bad, a simple issset($_SESSION) is not enough. another session might be set somewhere else.


1 Answers

The redirect after logout is hard coded in the trait AuthenticatesAndRegistersUsers. You can override it in your AuthController by adding this:

public function getLogout()
{
    $this->auth->logout();

    return redirect('logout');
}
like image 180
lukasgeiter Avatar answered Nov 01 '22 21:11

lukasgeiter