开发者

facebook session check on login

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜