私のログイン方法:
public function login() {
if ($this->request->is('post')) {
if ($this->Auth->login()) {
return $this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash('Please enter a valid username or password', 'errors/flash_error');
}
}
}
何らかの理由で、リダイレクト先のページにセッション情報が常に表示されるとは限りません。/random
次の宛先にルーティングされるというページがあります。
Router::connect('/random', array('controller' => 'submissions', 'action' => 'random'));
に行くと/random
、これは表示されません:
<?= $this->Session->read('Auth.User.username'); ?>
しかし、他のページに行くと、そうなります。
私のSubmissionsController.phpでbeforeFilter()
:
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->loginRedirect = array(
'controller' => 'users',
'action' => 'login');
$this->Auth->allow(
'popular',
'newest',
'random',
'view',
'category',
);
$this->Auth->flash['element'] = 'errors/flash_error';
$this->Auth->authError = 'Please login or sign up to submit a link.';
}
上記の、、、で動作しpopular
ますnewest
が、または..view
では動作しません。random
category
なぜですか?