When a user clicks a link that requires a log in, we currently redirect them to the log-in page ,but we lose the intended URL. What is the best way to account for that URL and redirect the user to the requested page once logged in?
We're using the latest stable version of Cake. Thanks.
--Edit--
Its configured like this
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
// $this->Auth->autoRedirect = false;
$this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'dashboard');
login function in users_controller
function login() {
Debugger::log("Redirect Session Key:" . $this->Session->read('Auth.redirect'), $level = 7);
$ref = $this->referer();
Debugger::log("referer():" . $ref, $level = 7);
}
When I navigate to an unauthorized page like localhost/mysite/unauthorized I am redirected to localhost/mysite/users/login. In my debug.log file The Redirect Session Key prints out as users/dashboard which implies that there is no valid referrer. To validate that assumption I also print out the referrer in the login function which does in fact return "/" which is the default value in the case of no referrer information from the requester I believe.