フロントエンドに customers_contoller.php があります
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;
}
}
}
モデル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;
}
ほとんどの場合、ログインは正常に機能しますが、ログインが機能せず、エラー メッセージが表示されないこともあります。ログイン時に毎回ページのみを更新します。
その時点で自分のウェブサイトにログインできない場合、ブラウザのキャッシュにセッションパスの「/ app /」が表示されますが、 app_controller.phpのbefore_filter()関数で実際のセッションパスを設定しました$this->Session->path = '/';
ブラウザのキャッシュをすべて削除してログインを試みるだけで、問題なく動作しています。
誰が私に何が問題なのか説明できますか? ランダムに発生するため、問題の根本を見つけることができません。