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 :
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.