문제

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