I'm trying to save the session in a variable url which the user tries to enter, if the user is not logged in, so I redirect to the login URL and once it has been logged successfully redirect back to the website that had requested. My problem is that it does not save the session variable or from one side or the other.
This in appController
if($this->action!='logout' && $this->action!='logout_cas' && $this->action!='login_cas' && $this->action!='login'){
if(isset($_SESSION['cas_user'])){
$_SESSION['url_user'] = Router::url('', true);
$this->redirect(array('controller'=>'users','action'=>'login_cas'));
}
}
This in UsersController in function login_cas
if ($this->Auth->user('active') != '1') {
$active = $this->Auth->user('active');
$this->Session->destroy();
if($active < 0)
throw new Exception(__('Invalid user or password. Try again'));
throw new Exception(__('User blocked, contact your administrator'));
} else {
$_SESSION["user_login_errors"] = 0;
//$this->redirect(array('controller'=>'users','action'=>'home'));
$this->redirect($_SESSION['url_user']);
}
Message Notice (8): Undefined index: url_user