I had this same issue with modx revolution, in case it’s not clear from this thread, which it wasn’t, this is how you start sessions from outside scripts:
http://www.philiptrew.com/webdevelopment/modx/session-variables.html
// Include files to declare the MODx core class
require_once '/path_to_your/config.core.php';
require_once MODX_CORE_PATH.'config/'.MODX_CONFIG_KEY.'.inc.php';
require_once MODX_CORE_PATH.'model/modx/modx.class.php';
// Create an instance of the MODx core
$modx = new modX();
// Initialise the core to access the default 'web' context
$modx->initialize('web');
// Set a value in the desired session variable
$_SESSION['my_session_variable']='my_value';
You can set the first value that is gotten from: require_once ’/path_to_your/config.core.php’;
which just declares two modx globals, like this:
define('MODX_CORE_PATH', '/full/path/to/modxcore/' );
define('MODX_CONFIG_KEY', 'config');
which would give you:
define('MODX_CORE_PATH', '/full/path/to/modxcore/' );
define('MODX_CONFIG_KEY', 'config');
require_once ( MODX_CORE_PATH.'config/'.MODX_CONFIG_KEY.'.inc.php' );
require_once ( MODX_CORE_PATH.'model/modx/modx.class.php' );
// Create an instance of the MODx core
$modx = new modX();
// Initialise the core to access the default 'web' context
$modx->initialize('web');
I’m running a very complex external application that needs a lot of session support, and this fix was the solution, now all the little glitches are gone. Simply create an include and add this to the top of each php file that needs it. Works, and solves the session issue, which as far as I know, is not possible to resolve without this method.
Important: you must accept the default modx session name, do not try to mess with that. That’s probably going to be PHPSESSID, but verify this by checking your session cookies for the site, do not assume it. Also remember that modx revolution requires cookies, so SID appending to url isn’t going to work for you, you have to do the cookie checking explicitly if you require that.
Thanks to the site that solved this issue, but since this thread came up in google search for the modx revolution start external script sessions, I thought I’d add the real solution to it