MODx :: Get Session ID set by MODx to use in Module

余生颓废 提交于 2019-12-12 01:08:49

问题


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

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.

I have tried using

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

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

Any ideas?


回答1:


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

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();


来源:https://stackoverflow.com/questions/5044326/modx-get-session-id-set-by-modx-to-use-in-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!