@nasirnobin You need to set the intended URL before redirecting to login.
$request->session()->put('url.intended', url('/intended-url'));
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have an e-commerce site. When user going to checkout page, they need to login to the system. After authentication, the page will redirect to checkout page. I used multi-table-auth in my e-commerce website (https://scotch.io/@sukelali/how-to-create-multi-table-authentication-in-laravel). I used redirect()->intended(), which is not working. I also searched for result in online, nothing seems to working for my situation. Can anyone help me out! Here is my code for login:
use AuthenticatesUsers;
protected $redirectTo = '/';
public function __construct()
{
$this->middleware('guest')->except('logout');
}
public function guard()
{
return Auth::guard('customer');
}
public function login(Request $request)
{
$rememberMe = $request->remember ? true : false;
$customer = Customer::where(['phone' => $request->phone, 'password' => $request->pin])->first();
if (!empty($customer)) {
Auth::guard('customer')->login($customer, $rememberMe);
return redirect()->intended('landing_page');
}
return back()->withInput()->withErrors(['Invalid Credential!']);
}
@nasirnobin You need to set the intended URL before redirecting to login.
$request->session()->put('url.intended', url('/intended-url'));
Please or to participate in this conversation.