Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By skatun on
I wonder how I can get acsess to the session variable that contains the username in Drupal. I need this in my own php code to select which database I am going to use.
Comments
Add this: global $user; and
Add this: global $user; and use $user->name for the username and $user->uid for the user's id.