我正在使用 cakephp 3.2
我必须从一个 Action 重定向到另一个 Action 以及一些数据。要传输的数据量大、易变且敏感。
传递参数中的数据可以通过
return $this->redirect(['controller' => 'MyController', 'action' => 'myAction', $param]);
但这给出了 url 作为
/my-controller/my-action/param
我不想在 url 中显示 param
。
有什么办法可以做到这一点吗?
最佳答案
Is there some way to do this ?
您可以简单地使用 session 来存储数据。
例如在带有发布数据的函数中:
$this->request->session()->write(
'my-stuff',
$this->request->data
);
$this->redirect('/somewhere/else');
在需要该数据的函数中,从 session 中读取它:
$myStuff = $this->request->session()->read('my-stuff');
if (!$myStuff) {
return $this->redirect('/start/point');
}
...
关于cakephp - 在 cakephp 3 中使用隐藏或后置参数重定向到另一个操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39556221/