1

I really need to use $this->Session->read('id') in one of the model's method therefore I need to include Session component in the model. How can I do that? public $component = array('Session'); doesn't work like in the Controller.

2 Answers 2

6

the component should be and is limited to the controller.

but you can use the static access:

CakeSession::read('Auth.User.id')

etc

0

For using session inside the custom component I tried with

public $components = array('Session');

and then called it by using

$this->Session->read('Auth.User.id');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.