1

我有此代码,但 Flash 消息显示不正确。

我想在以下位置显示消息:

http://xxx/cake/ ----(add action)

但实际上消息显示在:

http://xxx/cake/users/ ----(index action)

我该如何解决这个问题?我对激活没有任何看法。我只想重定向到添加操作并在此之后显示 Flash 消息。


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'));
4

2 回答 2

0

只需销毁此会话:

array
  'fb_400xxxxxxx96_state' => string 'ce3xxasdxxxxxxasdasdxxxxxxxf' (length=32)

    public function add() {
        $this->Session->destroy();

        //some code

    }
于 2012-08-16T21:55:16.533 回答
0

也许你应该看看这个涵盖这个的tuto

于 2012-08-19T17:04:06.213 回答