I want to define a variable in cakephp that can be accessed from anywhere (i.e model,controller,component etc.) without using session. How to achieve this in cakephp, any suggestion?
You could define constants in app/Config/bootstrap.php, but a better solution would be use Configure::write();
For example if you want read some variable anywhere, you can set it in bootstrap.php file (app/Config/) or in Your AppController.php (app/Controllers) by:
Configure::write('variable_name', 'variable_value');
and read it anywhere by:
Configure::read('variable_name');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With