简体   繁体   中英

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

I need to find the user who is logged into the current session. I tried the following but does not work: Can anyone help me? Thanks in advance!

$.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);
    }
});

I tried the following and it works for me.

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项目,你要求吗?

The REST call that you are making requires that you have a SESSION token. Normally, we will setup a REST user on our CRM's that can be accessed via REST.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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