2
votes

First I am not a joomla developer. My friend has a web site created with joomla 1.5. In webroot there are some joomla files. I created a directory in webroot "mydirectory" and i have an index file in this directory. I try to access joomla's user info in this page i grab the user object but it doesn't work.

 //i included joomla core  files
 $user =& JFactory::getUser();

 if ($user->get('guest')) {
     echo 'guest';
 } else {
 echo 'not guest';
 }

when I log in to my account, it says 'guest' again.

Also, I can't find anything in Joomla's session class.

$session =& JFactory::getSession();

Thanks

3
Could you post the contents on the index file? - Elitmiar

3 Answers

7
votes

You should do this:

$user =& JFactory::getUser();

if (!$user->guest) {
  echo 'You are logged in as:<br />';
  echo 'User name: ' . $user->username . '<br />';
  echo 'Real name: ' . $user->name . '<br />';
  echo 'User ID  : ' . $user->id . '<br />';
}

This is from here: http://docs.joomla.org/JFactory/getUser

3
votes

Try print_r($user) to see what items you are getting back.

2
votes
  1. Try to check for $user->id
  2. See if you are missing including any file e.g. framework.php