How can I redirect another page after login in Laravel?
“how to redirect to another page after login in laravel” Code Answer's
- protected function authenticated(Request $request, $user) {
- if ($user->role_id == 1) {
- return redirect('/admin');
- } else if ($user->role_id == 2) {
- return redirect('/author');
- } else {
- return redirect('/blog');
- }
How do I redirect to another page after login?
To do the redirect, use: header('Location: http://www.example.com/'); Also, please consider my advice.
How do I redirect back to the previous page after login success?
return redirect() ->back(); Normally, after successfully logged in, the best way to redirect to protected page is intended() .
Where should we redirect the request after authorization Laravel?
Laravel Auth features a function to redirect logged-in user to the same page they were visiting before. So, for example, if you visit /posts, you get automatically redirected to /login and then enter your data successfully, Laravel will “remember” and redirect you back to /posts instead of default /home.