简体   繁体   English

在cakephp 3中使用隐藏或发布参数重定向到另一个动作

[英]redirect to another action with hidden or post parameter in cakephp 3

I'm working cakephp 3.2 我正在工作cakephp 3.2

I have to redirect from one action to another along with some data with it. 我必须从一个动作重定向到另一个动作以及一些数据。 The data to be transmitted is large and in a variable and also sensitive. 要传输的数据很大,而且可变且敏感。

Passing the data in parameter can be achieved by 通过参数传递数据可以通过

return $this->redirect(['controller' => 'MyController', 'action' => 'myAction', $param]);

But this gives url as 但这给url作为

/my-controller/my-action/param

I do not want to show param in the url. 我不想在网址中显示param

Is there some way to do this ? 有什么办法可以做到这一点?

Is there some way to do this ? 有什么办法可以做到这一点?

You could simply use the session to stash the data. 您可以简单地使用会话来存储数据。

Eg In the function with post data: 例如,在具有后置数据的函数中:

$this->request->session()->write(
    'my-stuff', 
    $this->request->data
);
$this->redirect('/somewhere/else');

In the function that needs that data, read it out of the session: 在需要该数据的函数中,从会话中读取它:

$myStuff = $this->request->session()->read('my-stuff');
if (!$myStuff) {
    return $this->redirect('/start/point');
}
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM