Passing Variable in URL as a method's parameter
return $this->redirect([
'controller' => 'users',
'action' => 'profile',
$id
]);
Url should be looks like this http://your_app_url/users/profile/{id}
in UsersController.php file in profile() method
class UsersController extends Controller {
public function profile($id=null) {
$userData=$this->Users->get($id);
}
}
Passing variable in URL as a Query String
return $this->redirect([
'controller' => 'users',
'action' => 'profile',
'?'=>['id'=>$id]
]);
Url should be looks like this http://your_app_url/users/profile/?id={id}
in UsersController.php file in profile() method
class UsersController extends Controller {
public function profile() {
$userData=$this->Users->get($this->request->query('id'));
}
}