簡體   English   中英

在cakephp 3中使用隱藏或發布參數重定向到另一個動作

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

我正在工作cakephp 3.2

我必須從一個動作重定向到另一個動作以及一些數據。 要傳輸的數據很大,而且可變且敏感。

通過參數傳遞數據可以通過

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

但這給url作為

/my-controller/my-action/param

我不想在網址中顯示param

有什么辦法可以做到這一點?

有什么辦法可以做到這一點?

您可以簡單地使用會話來存儲數據。

例如,在具有后置數據的函數中:

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

在需要該數據的函數中,從會話中讀取它:

$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