title: Detect changes to the Facebook session
body: <p>The look of my site depends heavily on whether the user is logged in via Facebook and resultantly, it is very important for me to detect any changes in the Facebook Session as soon as they occur in order for me to adapt the look of the page to reflect the users login status. I hate using intervals and timeouts for this sort of code as things can get really messy, but it appears to be the only option (to the best of my knowledge).</p>
  
  <p>I have tried using the <code>FB.subscribe(auth.statusChange)</code>, but this does not seem to fire regularly enough and necessarily correctly. Maybe I am using it wrong?</p>
  
  <p><strong>The way I have tested the <code>FB.subscribe(auth.statusChange)</code>, is simply logging each time it is fired and intentionally logging in and out of Facebook on another tab. It seems that it takes around 30 minutes for the event to actually fire (and it does not always fire). Not only is this very hard to test as I have to wait 30 mins each time, it seems it does not necessarily fire correctly. Am I using it incorrectly?</strong></p>
  
  <p>The code I am thinking about using is something like this but I am not to happy with it as it uses timeouts/intervals:</p>
  
  <pre><code>window.fbAsyncInit=function(){
      // Initialize the Facebook object
      FB.init({
          appId:"123",
          status:true,
          cookie:true,
          xfbml:true,
          oauth:true
      });
      // Check the Facebook session status every 30 seconds
      setInterval(function(){
          FB.getLoginStatus(function(a){
              // Change the page look based on the facebook status
              fb_welcome(a.status)
          },true)}
      ,30000);
  };
  </code></pre>
  
  <p>Alternatively, I would rather use a timeout instead of an interval, but this requires me passing the Facebook object to another function like this:</p>
  
  <pre><code>// Check the Facebook session status every 30 seconds
  setTimeout(function(){
      // Pass the Facebook object to the welcome function
      fb_welcome(FB);
  ,30000);
  </code></pre>
  
  <p>Is it a bad idea to pass the FB object to another function outside of the <code>fbAsyncInit</code> function?</p>