Joomla 2.5 check user logged in

2020-04-07 03:14发布

问题:

How do i check if a user is logged in in Joomla 2.5? I can only seem to find code snippets for the older versions of joomla. Is it the same?

回答1:

if(JFactory::getUser()->id)
{
//user has logged in
}


回答2:

Yes it same as before try this-

$user =& JFactory::getUser();
if($user->id!=0){
//user is logged in
}


回答3:

$user = JFactory::getUser()->guest;

If you are on PHP 5.3.