我有這個代碼驗證用戶登錄,它在localhost上正常工作,但在遠程服務器上不起作用。它只加載並保留在登錄頁面上。但是,當用戶名或密碼錯誤時,它會給出錯誤信息。CakeSession :: write()不工作在遠程服務器上,但在本地主機上正常工作
if($this->request->is('post')){
$data = $this->request->data;
$password = sha1($data['password']);
$email = $data['email'];
$authUser = $this->User->find('first', array('conditions' => array('User.email' =>
$email, 'User.password' => $password)));
if(count($authUser) > 0){
CakeSession::write('loggedInUser', $authUser['User']['id']);
CakeSession::write('loggedInName', $authUser['User']['first_name'].' '.$authUser['User']['last_name']);
CakeSession::write('verStatus', $authUser['User']['verified']);
if(null != CakeSession::read('loggedInUser')){
$this->redirect('/shop');
}
}else{
$loginError = 'Invalid username or password';
$this->set('invalid', $loginError);
}
}
任何人都可以知道發生了什麼嗎? 我的CakePHP的版本是2.5.4
爲什麼不使用'Auth'和'Session'組件?不要試圖重新發明輪子。 – ndm 2014-10-10 14:22:46