简体   繁体   中英

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

I'm working 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

/my-controller/my-action/param

I do not want to show param in the url.

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');
}
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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