如何获取登录到当前会话的用户的ID

How to get the ID of the user who is logged into the current session?

本文关键字:会话 用户 ID 登录 何获取 获取      更新时间:2023-09-26

我需要找到登录到当前会话的用户。我尝试了以下操作,但没有成功:有人能帮我吗?提前感谢!

$.get(CurrentServerAddress + '/service/v4/rest.php', {
    method: "get_user_id",
    input_type: "JSON",
    response_type: "JSON",
    rest_data:'"new_get_user_id":["session":"' + SugarSessionId + '"]'
}, function(data) {
    if (data !== undefined) {
        var userID = jQuery.parseJSON(data);
    }
});

我尝试了以下操作,它对我有效。

var userID = '';
    $.get(CurrentServerAddress + '/service/v4/rest.php', {
        method: "get_user_id",
        input_type: "JSON",
        response_type: "JSON",
        rest_data: '[{"session":"' + SugarSessionId + '"}]'
    }, function(data) {
        if (data !== undefined) {
            userID = jQuery.parseJSON(data);
        }
    });
'authenticated_user_id'

据我所知,这是会话中您应该寻找的糖crm项目,您是否要求这样做?

您正在进行的REST调用要求您具有SESSION令牌。通常,我们会在CRM上设置一个REST用户,该用户可以通过REST访问。