Reputation: 221
I have to read session variable into bootstrap.php
file and have to assign this to a variable. When I am accessing session variable I am getting error:
Error: Call to a member function session() on null.
Below is my code.
$year=$this->request->session()->read('Auth.User.year');
Configure::write('Theme', [
'logo' => [
'large' => "<b>FlexiComs</b>$year"
],
]);
Upvotes: 0
Views: 213
Reputation: 25698
bootstrap.php is the wrong place.
Write the data to your config and write the data to the session in your app controllers initialize() by reading it there from your config.
App related logic does not belong into the bootstrap process.
Upvotes: 2