Hello, Using this from BaseConroller:
$this->persistent->myvar = $audit->getWebserviceAuditID();
All other controllers can access this variable then. like:
$this->persistent->myvar
Is there a way to access this variable from main index.php front controller - i.e. which is defined as a such:
class Micro extends \Phalcon\Mvc\Micro
This does not work:
echo "Welcome, ", $app->persistent->myvar;
When I dump $app->persistent, I see there is an object with variable filled with value:
["persistent"]=> object(Phalcon\Session\Bag)#66 (5) { ["_dependencyInjector":protected]=> RECURSION ["_name":protected]=> string(31) "Com\MycategoryController" ["_data":protected]=> array(1) { ["myvar"]=> string(3) "981" } ["_initialized":protected]=> bool(true) ["_session":protected]=> object(Phalcon\Session\Adapter\Files)#67 (3) { ["_uniqueId":protected]=> NULL ["_started":protected]=> bool(false) ["_options":protected]=> NULL } }
As we see, there is my data:
["_data":protected]=> array(1) { ["myvar"]=> string(3) "981" }
I just cannot figure it out how to access this value?!
Dump here returns NULL for both:
var_dump($app->persistent->myvar, $app->persistent['myvar']);