I have customers_contoller.php in frontend
function login() {
if(!empty($this->data)) {
# Call function from Customer to insert Registration Data
$loginData = ClassRegistry::init('Customer')->checkLogin($this->data['email'], $this->data['password']);
if(isset($loginData) && !empty($loginData)) {
$this->Session->write('Session.userid',$loginData['Customer']['id']);
$this->Session->write('Session.email',$loginData['Customer']['email']);
$this->redirect(HTTP_PATH."my-profile");
exit;
} else {
$this->Session->setFlash('Please enter valid Username/Password','default',array('class'=>'flash_bad'));
$this->redirect(HTTP_PATH."customer/login");
exit;
}
}
}
and in model customer.php,
function checkLogin($email,$password) {
$loginData = $this->find('first', array('conditions' => array('Customer.email' => $email, 'Customer.password' => sha1($password), 'Customer.is_active' => 'Yes')));
return $loginData;
}
most of time Login working fine, but sometime login not working and also doesn't get Error Message. Only refresh page every time on login.
I have just check all this things i found that when i can't login in my website at that time browser's cache show '/app/' for Session path but i have set actual Session path in before_filter() function in app_controller.php using $this->Session->path = '/';
I just remove all the browser's cache and try for login, now it is working fine.
Can anyone explain me what is the issue? it occurs randomly so i can't find root of the issue.