php - Check if a user logged in or not: Drupal -


i want check if user logged in or not in drupal. if user logged in, print something. otherwise nothing. checking follows:

global $user; if($user->uid) {   echo "logged in'; } else {    echo "not logged in"; } 

but, in case, showing 'not logged in' either user logged in or not. tried echo $user->uid also. not printing anything. can issue???

there's no need use global variable here. use user_is_logged_in() function (available drupal 6+).

if (user_is_logged_in()) {     echo "logged in"; } else {     echo "not logged in"; } 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -