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?
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.