Reputation: 11
Does auth store any variables in the session (e.g. username, other user model properties)? If so, how do I access them? If not, how would I place those variables into the session? In the User controller login function? Thanks, I'm a noob at cakephp
Upvotes: 1
Views: 6852
Reputation: 3226
After the user is logged in successfully, all his information will be available in the session..
the best way (CakePHP) to get the user's information from the session is:
$this->Auth->user();
you should call this from your controller..
it will give you all the user's information,
if you need a specific information (e.g. username
):
$this->Auth->user ( 'username' );
and if you want to access the session from a view, you can use:
$session->read ( 'Auth.User' );
or again (for username
):
$session->read ( 'Auth.User.username' );
hope this helps..
good luck with your development..
Upvotes: 5