سؤال

I have the name of my user in $_SESSION["login"], and I'm trying to display this in Joomla, however shows the following "", and doesn't print anything.

In the PHP class, the variable appears correctly, but in Joomla it doesn't.

هل كانت مفيدة؟

المحلول

If the end goal is to get information regarding the currently logged in user, you should simply use the below core utility function to grab the current User object with all the info you could need.

$user = JFactory::getUser();
echo $user->username;
echo $user->id;
echo $user->email;
// and so on

نصائح أخرى

You can use session in joomla with: JFactory::getSession() as follow:

$session = &JFactory::getSession();
$session->set("login","session_value")

and to get this session

$session->get("login")

Thanks.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top