简体   繁体   中英

Get User Session logged only to Joomla Backend

I'm using Joomla 2.5.27 and i need to create a php and get the session of logged in user in backend.

I have that code that i found on the webs

define( '_JEXEC', 1 );
define( 'JPATH_BASE', realpath(dirname(dirname(__FILE__))));
require_once ( JPATH_BASE . '/includes/defines.php' );
require_once ( JPATH_BASE . '/includes/framework.php' );
$mainframe =& JFactory::getApplication('administrator');
$mainframe->initialise();
$user =& JFactory::getUser();
$session =& JFactory::getSession();
header('Content-Type: application/json');
echo json_encode($session);

so the problem that if the user is logged to frontend then it returns the user that is logged. But if it is logged only to backend this code returns guest user.

Can anyone explain me if it is possible to get backend session?
the php file with the code above is located in administrator path

通过从浏览器清除cookie解决了问题,现在它可以正常运行并且始终正常!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM