我有此代码,但闪存消息显示不正确。
我想在以下位置显示消息:
http://xxx/cake/ ----(add action)
但实际上消息显示在:
http://xxx/cake/users/ ----(index action)
我该如何解决这个问题?我对激活没有任何看法。我只想重定向到添加操作并在此之后显示闪烁消息。
class UsersController extends AppController {
public function index() {
$this->User->recursive = 0;
$this->set('users', $this->paginate());
}
public function add() {
}
public function activation() {
$email = $this->request->query['email'];
$codeLink = $this->request->query['code'];
if($this->User->activationAccount($email, $codeLink)) {
$this->Session->setFlash(__('Success'));///should be shown in add
$this->redirect(array('action' => 'add'));
}
else {
$this->Session->setFlash(__('Error.'));//should be shown in add
$this->redirect(array('action' => 'add'));
}
}
}
路线.php
Router::connect('/', array('controller' => 'users', 'action' => 'add'));
只需销毁此会话:
array
'fb_400xxxxxxx96_state' => string 'ce3xxasdxxxxxxasdasdxxxxxxxf' (length=32)
public function add() {
$this->Session->destroy();
//some code
}
也许你应该看看这个tuto,它涵盖了这个