We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44969
    • 16 Posts
    Hello!

    I have a site (Revo 2.5.2) that passes some data to a standalone script using the jquery load() method. I want to be able to get the current modx user id in that standalone script so I can use it to validate the data (obviously I don't want to pass the user id along with the data). I have included the following lines in my standalone script and they allow me to use modx to handle my database requests, but I can't do certain other things like get the user id or load chunks -- I don't get errors, but the results are always empty.

    require_once '/path/to/my/config.core.php';
    require_once MODX_CORE_PATH.'model/modx/modx.class.php';
    $modx = new modX();
    $modx->initialize('web');
    $modx->getService('error','error.modError', '', '');

    Do I need to load some other services or modx objects for $modx->user->id to have a value in my standalone script?

    Thanks for any help anyone can provide!

    This question has been answered by seriouslythough. See the first response.

    • discuss.answer
      • 44969
      • 16 Posts
      Hello again,

      I solved this by removing session_start() from the standalone script. As per this thread, it was stopping the modx session handler from running:

      https://forums.modx.com/index.php/topic,53891.msg378109.html

      Thanks to spikku for answering this five and a half years ago!