Keyur Padalia
Keyur Padalia

Reputation: 2097

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

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?

Upvotes: 3

Views: 624

Answers (1)

Rayann Nayran
Rayann Nayran

Reputation: 1135

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');

Upvotes: 1

Related Questions