access joomla session in php - codeigniter(在 php 中访问 joomla 会话 - codeigniter)
问题描述
我需要在 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' );
但我收到了这条消息:
未找到配置文件,也没有可用的安装代码.退出...
No configuration file found and no installation code available. Exiting...
Joomla 安装在 root 上,codeigniter 安装在 root/advanced 上
Joomla is installed on root and codeigniter on root/advanced
我正在调用控制器中的代码.
I am calling the code in controller.
我该如何解决这个问题?
How can I solve this?
现在我收到此错误:
遇到 PHP 错误
严重性:注意
消息:未定义变量: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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 php 中访问 joomla 会话 - codeigniter


基础教程推荐
- 在多维数组中查找最大值 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01