How do I access SESSIONs in CakePHP's app.php?

664 views Asked by At

I am using CakePHP 3.3

I am trying to set session timeout's value and other settings in app.php to a value stored in config database table.

I tried using the line below but it's just stoping execution of the webpage.

$myConfigs = Cake\View\Helper\SessionHelper::read('my_configs');

Can anyone please let me know how do I access session out side controller and model, OR is there a way to set values of the variables in app.php in controller?

1

There are 1 answers

0
Rayann Nayran On

You could use Cake\Core\Configure to override and creating new settings.

use Cake\Core\Configure;

Configure::write('Session', [
    'defaults' => 'php',
    'cookie' => 'my_app',
    'timeout' => 4320 // 3 days
]);

$timeout = Configure::read('Session.timeout');