Global variable to check Drupal user authentication

1 Comment(s)

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

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

Leave a Reply

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

+ 84 = 94

Looking for any specific topic / article?


Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages

Most popular searches: Technology, Website, AI

Enjoy this blog?

Your may interested in our latest blogs

Stay Updated

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