Joomla Check If User Logged In

In this tutorial I will show you how to check if a user is logged into your Joomla website using code. This is used in your custom components, modules, plugins.

Step 1
First we will get the current user object using the following code

$user  = JFactory::getUser();

Step 2
Next we will check if the user is a guest

if($user->guest){
   // The user is not logged
}else{
   // The user is logged in so continue.
}

That’s it. As you can see it is a very simple code but works great. Leave a comment and follow us on Twitter.

Please Post Your Comments & Reviews

Welcome to Western Studios

We provide professional website and mobile softwares including Joomla, Wordpress and more.