I am using CakePHP 2.0’s integrated Auth component.
I have the following tables :
- Users
- Groups
- Profiles
My model relations are as follows:
User belongsTo Group
User hasMany Profiles
While logged in to the site, I noticed the Auth session contains only User table information, but I need the information of Groups and Profiles tables too for the logged in user.
Is there any way to do that with the Auth component?
There is no way to do this with the
AuthComponentbecause of the way it handles the session keys. You can, however, just save it to the session yourself.The only way to do this is to add to the session when the user logs in:
Then in your
beforeFilter()in yourAppController, save a var for the controllers to get to:Update: As of CakePHP 2.2 (announced here), the AuthComponent now accepts the ‘contain’ key for storing extra information in the session.