Issue
I think it is necessary to access the session data from every where especially in the model, I don't know what is the conflict with the design or logic of CakePHP.
I wonder if we can use the Session class globally as Text class.
Does the problem just about the design and logic and nothing related to errors can be rises in the future?
Solution
As per Framework concept you can read/write/modify session from Controller.But have not read and write access in Model.
In CakePHP v3 you can manage session in model as mentioned below
\Cake\Routing\Router::getRequest()->session()->read('key');
\Cake\Routing\Router::getRequest()->session()->write('key', 'value');
Answered By - Haresh Vidja
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.