I have this code but the flash message is displayed incorrectly.
I want to display the message in:
http://xxx/cake/ ----(add action)
but actually the message is shown in:
http://xxx/cake/users/ ----(index action)
How can i solve this? I don’t have any view to activation. I just want redirect to the add action and display the flash message after that.
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'));
}
}
}
routes.php
Router::connect('/', array('controller' => 'users', 'action' => 'add'));
Just destroy this session: