I had built an external application which retrieve Joomla User Information and I user the code as below :
session_start();
define( '_JEXEC', 1 );
define('JPATH_BASE', '../' );
require_once ( JPATH_BASE .'../includes/defines.php' );
require_once ( JPATH_BASE .'../includes/framework.php' );
$app = JFactory::getApplication('site');
$user = JFactory::getUser();
$myuserid = $user->username;
$_SESSION["myid"] = "$myuserid";
$myid = $_SESSION["myid"];
echo 'User name: ' . $myid . '<br />';
However, the output of $myid is not displayed in the site. It just displayed as :
User name :
The displayed should be :
User name : admin
Is there's a problem with my coding? Any help will be appreciated.
Try this,
I think the framework not loaded correctly on the external page.
Do not use
session_start()
for Joomla If you need to use session try Joomla session library.In your case the logged in admin name will be.
Hope it works..