Search code examples
http-redirectauthenticationlaravel-5.3

Laravel 5.3 Redirect to previous page after login success


i have /privatepage that only authenticated user able to access

questions:

  1. how to redirect to /login, if i'm guest (not authenticated) and i hit /privatepage
  2. once i'm successfully login from /login, how to redirect to the previous page (/privatepage)
  3. similiar like no.2 - in /login page, if i come from /aboutpage (which a public page) - after login successfull, how do i redirect back to /aboutpage (or the previous page)?

Thank you,

AnD


Solution

  • Use redirect()->intended()

    Find more about it here: http://laravel.com/docs/5.3/authentication