Skip to content

Instantly share code, notes, and snippets.

@aikchun
Last active August 29, 2015 13:57
Show Gist options
  • Save aikchun/9636588 to your computer and use it in GitHub Desktop.
Save aikchun/9636588 to your computer and use it in GitHub Desktop.
how to access variabel passed in through redirect
public function view() {
if($this->request->is('post')) {
$data = $this->request->data['HashAlgorithm'];
$this->log($data);
$this->redirect(array('controller' => 'HashResults' ,'action' => 'inputPlaintext', $data));
}
$conditions = array(
'fields' => array('name'),
'order' => array('name ASC')
);
$this->Session->destroy();
$data = $this->HashAlgorithm->find('all', $conditions);
$this->set('data', $data);
}
/**
* in HashResult controller
*/
public function inputPlaintext() {
// how do I access $data.
}
@simkimsia
Copy link

try this

/**
    * in HashResult controller
    */
    public function inputPlaintext($data) {
    // how do I access $data.
    }

I think $data should be either string or number. Unlikely to handle array. But not 100% certain. Just try the above first and $this->log to let me know if it works.

@aikchun
Copy link
Author

aikchun commented Mar 19, 2014

$this->redirect(array('controller' => 'HashResults' ,'action' => 'inputPlaintext', 'myString' => 'Hello World'));

public function inputPlaintext() {
$data = $this->request->myString;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment