0

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"
        ],
   ]);
Cœur
  • 37,241
  • 25
  • 195
  • 267
Devendra
  • 219
  • 2
  • 22

1 Answers1

2

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.

floriank
  • 25,546
  • 9
  • 42
  • 66