I have created app where I used the AuthComponent for user authentication.
It is working fine.
but I have created one function which login user with user data as follows.
protected function __login_user($conditions) {
$this->User->recursive = -1;
$userData = $this->User->find('first', array('condtions' => $conditions));
unset($userData['User']['password']);
if( !empty( $userData ) ) {
$this->Auth->login($userData['User']);
return true;
} else {
return false;
}
}
This function works fine when I login with ajax.
But if it is http request with post/get it work as::
It redirect me to the login redirect link, show the session for auth too just one time.
When I refresh the page the session get loss and logout.
Does anyone know why this happening?
return $this->Auth->login($userData['User']);. - Indrasinh Bihola