In Cakephp 2.0.6
I’m trying to make it so that user get redirected to the page he/she intended to go to prior to logging in so that after logging in it redirects to that page.
I’m using jQuery Mobile and Cakephp frameworks together.
public function login(){
$this->layout = 'jquery-mobile';
if ($this->request->is('post')) {
if ($this->Auth->login()) {
return $this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash(__('Username or password is incorrect'), 'default', array(), 'auth');
}
}
}
Above function seems to be working ok sometimes but not all the time.
Is there something I could do to ensure it happens all the time?
After succesfull login in login page controller
try this