[英]How can I use Joomla session from an external module?
I've created an external module for my website in Jooma. 我为Jooma的网站创建了一个外部模块。 I need to check if the user is logged, so I tried to load the file /libraries/import.php in order to use
JFactory::getSession()
but it exists in some point. 我需要检查用户是否已登录,因此为了使用
JFactory::getSession()
,我尝试加载文件/libraries/import.php ,但是它在某些时候存在。
How can I do that? 我怎样才能做到这一点?
Thank you. 谢谢。
Egidio 埃吉迪奥
try this, 尝试这个,
External Module means pure php file outside joomla right ? 外部模块意味着joomla之外的纯php文件,对吗? or its a joomla module ?.
或其joomla模块? If it is external file like below.
如果是如下所示的外部文件。
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";
Its joomla module like 它的joomla模块像
$user = JFactory::getUser();
if($user->id > 0)
echo "Logged In";
else
echo "Not logged In";
Hope it helps.. 希望能帮助到你..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.