Laravel 7 Redirect to Previous Page After Login Example

In this tutorial you will learn about the Laravel 7 Redirect to Previous Page After Login Example and its application with practical example.

In this laravel tutorial, I’ll show you how to redirect back to previous page after login in laravel project. In this tutorial you will learn to redirect user back to the previous page or url after login in laravel.

Laravel 7 Redirect to Previous Page After Login Example

In this article I’ll you show you two different methods to redirect user back to previous page after login.

First Method : How to redirect user Previous Page After Login

Open your loginContorller.php file then add this showLoginForm() method as following:

In this function we will be setting the “url.intended” session variable. Laravel uses this variable to check for the page to which user will be redirected after login.

Second Method : Laravel redirect user Previous Page After Login

In this method, you have to put the following code in LoginController’s __construct()method as follow:

As follow:

In this tutorial we have learn about the Laravel 7 Redirect to Previous Page After Login Example and its application with practical example. I hope you will like this tutorial.