CakePHP : Accessing the logged in user

Once a user is logged in, you will often need some particular information about the current user. You can access the currently logged in user using AuthComponent::user(). This method is static, and can be used globally after the AuthComponent has been loaded. You can access it both as an instance method or as a static method:

You can access all the user's information(fields) from the users table except the password.

// Use anywhere 
// Accesing user’s id

// Accesing user’s username

// Accesing user’s group_id

// and so on…

// From inside the controller
// Accessing user's id

// Accessing user's username

// and so on…

Post a Comment

Popular posts from this blog

CakeAdminLTE is based on AdminLTE Theme for CakePHP 2.4+

CakePHP: COUNT data and GROUP BY date

CakePHP: Calling function from other controller