我在Jooma中为我的网站创建了一个外部模块。我需要检查用户是否已记录,所以我尝试加载文件/libraries/import.php 以便使用JFactory::getSession()
但它存在于某个时候。
我该怎么做?
谢谢。
埃吉迪奥
试试这个,
外部模块意味着Joomla之外的纯php文件,或者它是一个Joomla模块。如果是如下所示的外部文件。
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );//this is when we are in the root
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe = JFactory::getApplication('site');
$mainframe->initialise();
$session = JFactory::getSession();
$user = JFactory::getUser();
if($user->id > 0)
echo "Logged In";
else
echo "Not logged In";
它的 joomla 模块喜欢
$user = JFactory::getUser();
if($user->id > 0)
echo "Logged In";
else
echo "Not logged In";
希望对您有所帮助。