0

I recently started playing with Joomla. So I found out that Joomla has a built-in user creation and log-in system even for the users of the front site. So I was wondering, what is the way to retrieve the details of a user's session, most importantly the username, and any other one, to produce personalized content,e.g. in a php script, when that user makes a request to the site?

0

To get the details of a logged in user use:

$user = JFactory::getUser();

The $user variable will contain your needed information from the database, e.g.:

$email = $user->email;

Use var_dump($user); to see what other fields you have available.

  • I'm sorry, but I can't get to use the classes needed. Is there an easy way to import them? (including import.php failed to solve my problem) – Noob Doob Jul 28 '15 at 10:20
  • Well if it's a script outside of Joomla then you probably won't be able to access the user's session. Maybe you should update your question with some more information and code. – fruppel Jul 28 '15 at 10:29
  • Or another question. When all works, I will accept this too. – Noob Doob Jul 28 '15 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.