javascript Joomla 2.5 检查用户登录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13174556/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 17:59:42  来源:igfitidea点击:

Joomla 2.5 check user logged in

phpjavascripthtmlcssjoomla

提问by Sean Lang

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?

我如何检查用户是否已登录 Joomla 2.5?我似乎只能找到旧版本的 joomla 的代码片段。是一样的吗?

回答by Techie

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

回答by Irfan

Yes it same as before try this-

是的,和以前一样试试这个-

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

回答by Elin

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

If you are on PHP 5.3.

如果您使用的是PHP 5.3