Issue with $this->Session in CakePHP

Well after struggling for 4hrs with an issue that appeared to be very simple, I had looked for the root cause in the code, dug in Apache Logs, config files, framework code and other stuff, I finally found what was causing this:

Notice (8): Undefined property: MyControllerController::$Session [APP/controllers/my_controller_controller.php, line 39]

MyControllerController::sendEmail() – APP/controllers/my_controller_controller.php, line 39
Dispatcher::_invoke() – CORE/cake/dispatcher.php, line 204
Dispatcher::dispatch() – CORE/cake/dispatcher.php, line 171
[main] – APP/webroot/index.php, line 83

Fatal error: Call to a member function write() on a non-object in /Library/WebServer/Documents/app/controllers/my_controller_controller.php on line 39

Alright if you just finished all your search just like me, just add this in your controller:

And that’s it!