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