简体   繁体   English

我如何强制Joomla更新用户会话

[英]How do i force Joomla to update the user session

I'm updating the ACL for a given user on a PayPal callback. 我正在通过PayPal回调更新给定用户的ACL。 I'm doing this by updating the #__user_usergroup_map table directly. 我是通过直接更新#__user_usergroup_map表来实现的。 Now i need the user session to be updated with the new information without logging out and in again. 现在,我需要用新信息更新用户会话,而无需注销和再次登录。

From this question 's answers i tried the following: 从这个问题的答案,我尝试了以下操作:

$user = JFactory::getUser();
$session = JFactory::getSession();
$session->set('user', new JUser($user->id));

However this does not work for me and from JUser it looks like JUser has been deprecated. 但是,这对我不起作用,并且从JUser看来,JUser已被弃用。

Can anyone hint me in the right direction? 谁能向我暗示正确的方向?

I realized that the answer from the other question will actually work. 我意识到,另一个问题的答案实际上是有效的。

$user = JFactory::getUser();
$session = JFactory::getSession();
$session->set('user', new JUser($user->id));

The reason it wouldn't update the user session in my case is that this code was called on the callback from PayPal which do not hold the user session. 就我而言,它不会更新用户会话的原因是该代码是在不保存用户会话的PayPal回调中调用的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM