onlinecode

Laravel after login, redirect back to previous url ?

Laravel after login, redirect back to previous url ?

In this post we will give you information about Laravel after login, redirect back to previous url ?. Hear we will give you detail about Laravel after login, redirect back to previous url ?And how to use it also give you demo for it if it is necessary.

If you are working on laravel and you want to do like: How to redirect back to previous url, After login. after login user you can redirect his previous page as he was before. you can do this, i would like to give you two example. first example is using intended() and second one is using session but i don’t know more but i think intended() is not working proper in laravel 5 but you can try in laravel 4. but i am sure i gave you example with session that work well in both.

So, you can try any one and get your solution, 1. using intended() and 2. session.

Example 1:

public function loginPost()

{

if ($this->auth->attempt(array('email' => Input::get('email'), 'password' => Input::get('password')))){

return Redirect::intended();

}

return back();

}

Example 2:

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();

}

Try this……..

Hope this code and post will helped you for implement Laravel after login, redirect back to previous url ?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Exit mobile version