Global variable to check Drupal user authentication

In Drupal, the User is a core module of the CMS and is responsible for the user management section of Drupal websites. In this module a global variable is defined which returns the user Id (i.e, uid) of the currently logged user. All the users are stored in users table in the database and once we have the primary key of the table we can fetch all the details of that particular user who have logged in. To get the user id (uid) of the currently logged user we will have to write this simple code : <?php global $user; echo $user->uid; ?> You can also access this variable from any modules or blocks throughout the site. E.g., blog module, poll module, node module, block module etc. [ratings]
Comments (1)

One response to “Global variable to check Drupal user authentication”

Leave a Reply

Your email address will not be published. Required fields are marked *

14 + = 19


Stay Updated

Please enter your details below to get
A Free Trial
x + x* =