Drupal 6: How to determine if User is Logged In or not

In Drupal, data for the current user is stored in the global variable $user. To determine if the user is logged in, use the following code:

<?php
    global $user;
    if ($user->uid) {
        // User is logged in.
    }
?>

This works because all guests browsing the site will have a uid of 0. That will return FALSE in the IF statement while any positive number will return TRUE. In Drupal, logged in users are referred to as authenticated users.


Bookmark and Share

0 comments :

Post a Comment

Hi there! Please leave your message here. Also, I may not be able to respond to your query right away. So please bear with me. Thanks. :)