开发者

facebook session check on login

开发者 https://www.devze.com 2023-02-28 14:26 出处:网络
I have put the following code in my head to check the session: <script type=\"text/javascript\">

I have put the following code in my head to check the session:

<script type="text/javascript">
            FB.getLoginStatus(function(response) {
              if (response.session) {
                alert('I am logged in');
              } else {
                alert('I am logged out');
  开发者_JAVA百科            }
            });
    </script>

however, it does not get executed on page load, why is this?


Make sure you have:

FB.init({
    appId  : APP_ID, // Your FB app ID from www.facebook.com/developers/
    status : true, // check login status
    cookie : true, // enable cookies to allow the server to access the session
    xfbml  : true  // parse XFBML
});

before any other FB reference in your scripts (using window.onload or similar) and

<DIV id="fb-root"></div> 

in the <body> section.

0

精彩评论

暂无评论...
验证码 换一张
取 消