i have a controller with multiple functions that have a variable inside them. I would like to access those variables from another function. Any ideas?
class RoomsController extends AppController {
public $helpers = array('Js' => 'Jquery');
public $components = array('RequestHandler');
function test1(){
$balcony = $_REQUEST['qwe'];
$this->set('qwe',$qwe);
}
function test2() {
$occy = $_REQUEST['wer'];
$this->set('wer',$wer);
}
function test3() {
$deck = $_REQUEST['ert'];
$this->set('ert',$ert);
}
function success() {
// i want to use $qwe, $wer and $ert here
}
any ideas on how to do this? do i have to set up global variables public $qwe;?
thanks
You can create controller properties but it will break the design of the framework, so I suggest using Configuration class for this purpose, you can store variable values and retrieve using this class, here’s a documentation:
http://book.cakephp.org/view/42/The-Configuration-Class
You can store variables in Session if you need their values after redirect:
and retrieve: