When you show the registration of the form, you can grab the intended url from session , if available, and pass it to the view, and then redirect using window.location .
So. how to capture intended url ?
$intended_url = Session::get('url.intended', url('/')); Session::forget('url.intended');
Here is the first argument to the intended url , if it is available in session , and the default is to use the home page using the url('/') helper method url('/') , so $intended_url will always contain the url that is intended or defaulr. Then, when you download the view, go through $intended_url using the following:
return View::make('login')->with('intended_url', $intended_url);
Then use it in the view, for example:
window.location = $intended_url;
Alternatively, you can configure View Composer , so whenever the login view / form is displayed, the intended url will be available in this and you can do this using this:
View::composer('login', function($view){ $intended_url = Session::get('url.intended', url('/')); Session::forget('url.intended'); return $view->with('intended_url', $intended_url); });
Here login is the name of the view for the login page, if this is something else in your case, then change it to the corresponding name of your login view. You can save this code in your app/start folder inside the file 'global.php' or save it in a separate file and include this file inside the global.php file using this (at the end):
require 'view_composer.php';
It is assumed that the file name will be view_composer.php , be present in the app/start folder.