This is just a bulletproof version of Redirect::to(), redirecting to an ABSOLUTE URL path like
"http://www.mydomain.com/user/profile", useful as people had problems with the RELATIVE URL path generated
by Redirect::to() when using HUGE inside sub-folders.
public static toPreviousViewedPageAfterLogin ( $path ) | ||
$path | string |
/** * The login action, when you do login/login */ public function login() { // check if csrf token is valid if (!Csrf::isTokenValid()) { LoginModel::logout(); Redirect::home(); exit; } // perform the login method, put result (true or false) into $login_successful $login_successful = LoginModel::login(Request::post('user_name'), Request::post('user_password'), Request::post('set_remember_me_cookie')); // check login status: if true, then redirect user to user/index, if false, then to login form again if ($login_successful) { if (Request::post('redirect')) { Redirect::toPreviousViewedPageAfterLogin(ltrim(urldecode(Request::post('redirect')), '/')); } else { Redirect::to('user/index'); } } else { if (Request::post('redirect')) { Redirect::to('login?redirect=' . ltrim(urlencode(Request::post('redirect')), '/')); } else { Redirect::to('login/index'); } } }