How to stay on the same page after a logout in Laravel How to stay on the same page after a logout in Laravel laravel laravel

How to stay on the same page after a logout in Laravel


Die you try:return Redirect::back();In your logout route/controller?


From a usability standpoint, I think it is a very good idea to send the user back to the page they were on after logging out, provided it is not a protected page.

It is actually quite easy to achieve. You need to make your logout link like this: example.com/logout?redir=about.html.

Now, after logging the user, check if $_GET['redir'] exists, and if it does, send them back to that page, other send them to the homepage. After logging out, and before redirecting to the same page, it might be a good idea to show them another page for a few seconds that says 'You've been logged out.'