I have a joomla website and have a PHP file in the root folder which fetches the current logged user perfectly.
I have another folder 'Files' which contains other HTML & PHP files. I need to kfetch the current logged user to work with these other HTML files.
Get_user.php // in the ROOT folder of the JOomla website and works fine !
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );//this is when we are in the root
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');
$mainframe->initialise();
$user = JFactory::getUser();
$uname = $user->username;
echo $uname;
//return $uname;
And this is my test.php file placed in http://www.mywebsite.com/files/test.php
<? php
$uname = include 'http://www.mywebsite.com/Get_user.php';
echo $uname;
?>
This always returns 1 where as i would like to have the user name. I tried with RETURN but doesn't work.
I have searched a lot in the forum but nothing seems to be working for me.
Can anyone please help me ?