在外部PHP中检索Joomla的Session

时间:2011-06-28 12:48:07

标签: php joomla1.5

  

可能重复:
  Accessing session data outside Joomla

我尝试使用下面的脚本来检索Joomla的Session,但它不起作用。 任何人都可以帮助我......

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');
$session     = &JFactory::getSession();

1 个答案:

答案 0 :(得分:0)

这就是我使用的:

    //Joomla Stuff
    define( '_JEXEC', '1' );
    define('JPATH_BASE', 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');

    /**
    * INITIALISE THE APPLICATION
    *
    * NOTE :
    */
    // set the language
    $mainframe->initialise();

    JPluginHelper::importPlugin('system');

    // trigger the onAfterInitialise events
    JDEBUG ? $_PROFILER->mark('afterInitialise') : null;
    $mainframe->triggerEvent('onAfterInitialise');
    // End Joomla Stuff