问题描述
我需要检查用户是否已登录CodeIgniter.
I need to check if the user is logged in or not in CodeIgniter.
登录正在Joomla网站上进行.
The login is happening in Joomla site.
我尝试了以下操作来初始化joomla.
I tried the following to initialize joomla .
define( '_JEXEC', 1 );
define( 'DS', DIRECTORY_SEPARATOR );
define('JPATH_BASE', dirname(__FILE__) );
require_once ("../includes/defines.php");
require_once ("../includes/framework.php");
$mainframe =& JFactory::getApplication("site");
$mainframe->initialise();
$session =& JFactory::getSession();
$user = $session->get( 'user' );
但我收到此消息:
Joomla安装在root上,而codeigniter安装在root/advanced上
Joomla is installed on root and codeigniter on root/advanced
我正在调用控制器中的代码.
I am calling the code in controller.
我该如何解决?
现在我收到此错误:
严重性:通知
消息:未定义的变量:BM
Message: Undefined variable: BM
文件名:core/CodeIgniter.php
Filename: core/CodeIgniter.php
行号:364
修改
我的控制器看起来像这样
My Controller look like this
function is_logged()
{
define( '_JEXEC', 1 );
define( 'JPATH_BASE', '../');
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
//require_once ("../libraries/joomla/user/authentication.php");
$mainframe =& JFactory::getApplication("site");
$mainframe->initialise();
$session =& JFactory::getSession();
$user = $session->get( 'user' );
}
目录结构
--Public_html
--Joomla Istallation files
--Advanced [This is a folder ,i installed codeignitor on this folder]
所以joomla的路径是site.com/
,而Codeignitor的路径是site.com/advanced
So the path to joomla is site.com/
and path to Codeignitor is site.com/advanced
有关错误的更多信息
Codeignitor Core上的第364行说:
Line 364 on Codeignitor Core says that :
// Mark a benchmark end point
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end');
我可以在CI核心的启动中看到以下内容
and i can see the following on the starting of CI core
$BM =& load_class('Benchmark', 'core');
$BM->mark('total_execution_time_start');
$BM->mark('loading_time:_base_classes_start');
推荐答案
我知道它是一篇老文章,但是您需要确保JPATH_BASE指向configuration.php文件所在的目录.我会使用绝对路径而不是相对路径.
I know its an old post but you need to make sure JPATH_BASE points to the directory where your configuration.php file is. I would use the absolute path rather than a relative path.
这篇关于在PHP中访问Joomla会话-Codeigniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!