Modx 3 session start code upgrade from 2.8.3 style

I recently did the upgrade from 2.8.3 to 3.0, which all seems to be working fine, site is running smoothly.

There is one thing I think I need to change due to it maybe causing a lot of deprecation errors. I use one bit of code across the site, which is a mix of Modx generated pages, and non modx pages, which starts modx session management (I want the modx session manager to run all the sessions on the site, whether or not it’s a Modx generated page).

I am not well versed in the new methods that Modx 3 uses with name spaces and so on, so I have no idea how to update this following code to run without generating deprecation notices in the modx logs:

define('MODX_CORE_PATH', '/www/site/core/' );
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 to start the session
// regardless if on modx generated page or not

As far as I can tell, this is working, but I believe support for this way of doing it will be dropped eventually in future Modx versions?

What is the correct way to code that block for Modx 3?

What that does is simply to start the Modx session manager, as far as I can tell, and has always worked fine on all past Modx versions, and seems to be still working now, but with deprecation warnings.

Thanks, long time Modx user, but don’t generally hit problems I can’t figure out myself, until this one.

I remember getting this session start code a long time ago from some documentation code sample, but couldn’t find anything like that in the updated documentation for 3.0.

Everything else seems good, site runs very fast with 3.0, so this is the only real issue I seem to have with the upgrade.

This article should help:

That worked fine, thanks. I’ll see if any other deprecation messages come up, but I think that was the main one.

I should add, deprecation notices are still appearing, I thought the ‘refresh’ button on the error/deprecation log section refreshed the deprecated alert log data, but apparently it doesn’t. I think though I’m not sure that the deprecation warnings are coming from Modx itself, they are all around not using the full name space path for Class loading, which seems to be in the current modx 3 code itself.

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.