Я пытаюсь настроить простую систему входа в систему, но у меня возникла конкретная проблема, которую я не могу решить.У меня есть следующие страницы, которые выполняют очевидные действия.Они добавлены в закладки для быстрого доступа.
cake/ (home page; must be logged in)
cake/login (must be logged in)
cake/logout (must be logged in)
cake/add (must be logged in)
Кажется, все работает, за исключением случаев, когда я выполняю следующую последовательность действий:
1. log in
2. go to cake/logout to log out (login works immediately after this step)
3. go to cake/logout again immediately
4. attempt to log in but cake/login is just re-displayed and I'm not logged in
5. attempt to log in again and it is successful
Я заметил, что $this->Session->flash('auth')
ЛОЖНО после шага3, но это не ложь после 4. Я попытался уничтожить сеанс до или после выхода из системы безрезультатно.Есть идеи?
Мои биты кода приведены ниже:
class UsersController extends AppController {
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('add');
}
public function add() {
if (!empty($this->data)) {
$this->User->create();
if ($this->User->save($this->data)) {
$this->Session->setFlash('User created!');
$this->redirect(array('action'=>'login'));
} else {
$this->Session->setFlash('Please correct the errors');
}
}
}
public function login() {
}
public function logout() {
$this->Session->destroy(); // makes no difference
$this->redirect($this->Auth->logout()); // redirected to login() by default
}
}
class AppController extends Controller {
public $components = array('Auth', 'Session');
}