I want to insert the logged in username into a variable for use in a page which is in the root directory of my Joomla instillation and displayed through a wrapper/iFrame.
Setting cookies in the main page does not work nor does the recommended way of accessing the user object with $user =& JFactory::getUser(); after the code below (link below). Any ideas?
define( '_JEXEC', 1 );
define( 'DS', DIRECTORY_SEPARATOR );
define( 'JPATH_BASE',$_SERVER['DOCUMENT_ROOT'].DS. basename(dirname(__DIR__)) );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
//optional use depend on requirement
jimport( 'joomla.user.user');
jimport( 'joomla.session.session');
jimport( 'joomla.user.authentication');