Accessing session data outside Joomla

前端 未结 15 1509
小鲜肉
小鲜肉 2020-12-08 03:36

I am trying to run an application outside Joomla (not as a plugin) and I would like to access the logged in user\'s information (userid). I am wondering how should I go abou

15条回答
  •  渐次进展
    2020-12-08 03:51

    The solution showed by Stefan Gehrig

    define( '_JEXEC', 1 );
    define('JPATH_BASE', dirname(dirname(__FILE__)));
    define( 'DS', DIRECTORY_SEPARATOR );
    
    require_once (JPATH_BASE . DS . 'includes' . DS . 'defines.php');
    require_once (JPATH_BASE . DS . 'includes' . DS . 'framework.php');
    
    $mainframe = JFactory::getApplication('site');
    

    works fine, I have spent many long nights trying access the Joomla! resources outside the joomla folder.

    $session     = &JFactory::getSession();
    

    In the follow up code, works fine when the getApplication method has been invoked.

    Thanks for solution.

提交回复
热议问题