I realize this might not be a clear cut “problem/answer” question, but I think it’s worth asking.
In controllers, it seems that there are three options which access the Auth object:
$this->Auth->user
$this->User
$user
They each return the record for the logged in user, and I cannot see much of a difference between them.
Now, it occurs to me that, at a glance, $this->User could be a bit confusing or unclear if working in an associated model $this->Posts->User.
But apart from that, is there a difference between these three options?
$this->Auth->user()returns the currently authenticated user from the session.$this->Useris a model and you won’t get the currently authenticated user unless you use the session data (either from Session or Auth component) to get the user id. Either way you’d have to do a query every request to get info about the logged in user.$user.. is just a variable. I don’t understand how this is an “options which access the Auth object”If you want info about the currently logged in user, use
$this->Auth->user();