Redirect User To Previous Page After Login In Laravel

In this tutorial we are going to show how to redirect user to previous page after authrntication. If you are working on laravel and you want to do like: How to redirect back to previous url, After login then this tutorial will definitely help you. After login user you can redirect his previous page as he was before.

It is very important for us because if you don’t know how to do it , then a user after login will be redirected to the home page which is not user friendly system in our application. So now let’s start tutorial.

redirect-previous-page-after-login-in-laravel

You can use this source code. Hope it will work for you.

 

public function login()
{
        Session::put('url.intended',URL::previous());
        return view('login');
}
public function loginPost()
{
    if ($this->auth->attempt(array('email' => Input::get('email'), 'password' => Input::get('password')))){
        return Redirect::to(Session::get('url.intended'));
    }
    return back();
}

 

Read more  :  Delete Multiple Records Via Checkbox Using jQuery Ajax in Laravel

 

Hope it will work for you. 

 

#laravel #redirect-user #redirect-page