Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

masum2's avatar

Redirect to the Previous Page After Registration and Login

I am new in Laravel and facing problem to redirect to the User or newly Registered User to the previous page after login or registration.

can anyone help me ?

0 likes
5 replies
morteza's avatar

Laravel already does it for you.

1 like
TomyLimon's avatar

return redirect()->intended('dashboard');

or

return redirect()->intended(Session::pull('referrer'));

biishmar's avatar

@masum2

For previous page

return back();

for specific page

return redirect()->route('routeName');
1 like
TomyLimon's avatar

Is it possible to get URL as a string? I need send it as JSON respons

Please or to participate in this conversation.