Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top