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?
1 Answer
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– Noob Doob2015-07-28 10:20:04 +00:00Commented Jul 28, 2015 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– fruppel2015-07-28 10:29:17 +00:00Commented Jul 28, 2015 at 10:29
- Or another question. When all works, I will accept this too.Noob Doob– Noob Doob2015-07-28 10:41:01 +00:00Commented Jul 28, 2015 at 10:41