Getting the facebook session at the server side if we login using JS SDK

前端 未结 3 816
慢半拍i
慢半拍i 2021-02-07 14:46

Friends,

I have set up a facebook login for my website using JS SDK.

  1. If the use is logged in through JS SDK, should we cross verify whether the session

3条回答
  •  长情又很酷
    2021-02-07 15:47

    The Facebook javascript library and the php SDK can essentially be considered two entities that do not talk to one another, as one is client-side, and the other is server-side.

    The php SDK gives you greater fine-grained control over a user's login session, while the javascript library is easier to get started.

    Typically, a user logged in via the javascript library is not automatically logged in on the server side, although in some cases, it may be possible to send the access token from client to server side. It is not advised, however, as this data can be intercepted.

    This related question talks about sending the access token (as retrieved from the JS library) to the server side.

    In essence:

    FB.login(function(response) {
        var access_token = response.authResponse.accessToken;
    
        // Make an ajax call here to your server-side, and send access_token in.
    });
    

提交回复
热议问题