cakePHP3: How to send parameters to an action via redirect()?

cakephp, cakephp-3.0

Solution

The above code only works if the login function is in the same controller and you do not need to return. else we need to define the controller as well for the redirect. Like :

$this->redirect(['controller'=>'YourController','action' => 'login', $user->username]);

Problem

In an action, I want to send send parameters to another action via redirect. So as I read this in the documentation (http://book.cakephp.org/3.0/en/controllers.html#redirecting-to-other-pages): ``` return $this->redirect(['action' => 'edit', $id]); ``` I wrote: ``` public function activate($user_id, $token) { //.... of course $user->username is not null here return $this->redirect(['action' => 'login', $user->username]); //.... } ``` And in my target action: ``` public function login($username = null) { //... debug($username); // just displays null //... } ``` I don't understand if the problem is in redirect() or in login(). Anyway debug($this->request) doesn't show any passed parameters. Regards,

Original source