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.