MODx :: Get由MODx设置的会话ID在模块中使用 [英] MODx :: Get Session ID set by MODx to use in Module

查看:221
本文介绍了MODx :: Get由MODx设置的会话ID在模块中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,我需要将会话ID传递给一个模块SMF Connector。

I have an issue where I need to pass the Session ID to a module, "SMF Connector".

问题出在某种原因SMF论坛(在一个子文件夹中保存)正在使用不同的会话集。我通过硬编码来自MODx的会话ID来解决这个问题,但是当我下次在一天后加载网站时,这会失败。

The problem stems from the fact that for some reason the SMF Forum (held in a sub-folder) is using a different Session set. I combatted the problem by hard coding the Session ID from MODx, but of course this then failed the next time I loaded up the site a day later.

我试过使用

global $modx;  
$SID = $modx->documentObject[SID];
session_id($SID);
session_start();

但没有效果,实际上是阻止整个论坛加载!

But to no avail, infact it was stopping the entire forum from loading!

任何想法?

推荐答案

原因是modx会话数据仅限于index.php和从那里包括的脚本。我想这是设计。

The reason is that modx session data is limited to index.php and scripts included from there. I suppose this is by design.

从我收集的,你的SMF脚本由一个单独的请求调用。请尝试在外部PHP脚本的开头添加以下行:

From what I gather, your SMF script is invoked by a seperate request. Try adding the following lines at the start of your external php script:

// start MODx session to access its session data
require_once ($_SERVER["DOCUMENT_ROOT"] . '/manager/includes/config.inc.php');
startCMSSession();

这篇关于MODx :: Get由MODx设置的会话ID在模块中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆