Take the 2-minute tour ×

I'm using Facebook's Javascript SDK to allow login/logout, and my problem is that when I use their window.fbAsyncInit call to initiate the FB session, it always fires twice. I've included a simplified code sample. I'd appreciate any help!

In the code below, the "2" alert fires a single time, and then the "1" alert fires twice.

<script type="text/javascript">
...some of my own functions, not related to Facebook...

window.fbAsyncInit = function() {
      appId   : '<?php echo FACEBOOK_APPID; ?>',
      session : <?php echo json_encode($session); ?>, status:false, cookie:true,  xfbml: true 


    FB.getLoginStatus(function(response) {
        if(response.session) { ...do stuff... } else { ...do other stuff...}



(function() {
    var e = document.createElement('script');
    e.async = true;

...page contents...
share|improve this question
Are you sure you're not including two different Facebook javascripts? –  julien_c Feb 28 '11 at 15:21

1 Answer 1

up vote 4 down vote accepted

You might accidentally be including two different Facebook javascripts.

share|improve this answer
INdeed, thsi was the problem. I caught it a while ago, but thanks! –  JoelD Apr 6 '11 at 4:09

Your Answer


