Question

I'm using joomla 3.2.

I have a wrapper menu item, and it's wrapper include the external php.

I'm connecting open joomla with this code:

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();

print_r ($user);

but my user object id is always 0. What could be happening?

Thanks for help.

Was it helpful?

Solution

Try the following script in your base Joomla folder:

<?php
// Initialize Joomla
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );

// Required Files
require_once (JPATH_BASE . '/includes/defines.php');
require_once (JPATH_BASE . '/includes/framework.php');

// To use Joomla's Database Class
require_once (JPATH_BASE .'/libraries/joomla/factory.php');

$app = JFactory::getApplication('site');
$user = JFactory::getUser();

echo '<pre>' . print_r ($user, true) . '</pre>';

You need to open another Joomla page and login there (same browser).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top