title: onlogin event not being triggered
body: <p>I have this page (most of it is from the facebook documentation, with minor changes). Since I'm a n00b with this, I'm posting the whole code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Reportes para Anunciantes&lt;/title&gt;
      &lt;meta charset="UTF-8"&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;script type="text/javascript"&gt;
          function statusChangeCallback(response) {
              console.log('statusChangeCallback');
              console.log(response);
              if (response.status === 'connected') {
                  // Logged into your app and Facebook.
                  testAPI();
              } else if (response.status === 'not_authorized') {
                  // The person is logged into Facebook, but not your app.
                  document.getElementById('status').innerHTML = 'Please log into this app.';
              } else {
                  // The person is not logged into Facebook, so we're not sure if
                  // they are logged into this app or not.
                  document.getElementById('status').innerHTML = 'Please log into Facebook.';
              }
          }
  
          // This function is called when someone finishes with the Login
          // Button.  See the onlogin handler attached to it in the sample
          // code below.
          function checkLoginState() {
              FB.getLoginStatus(function(response) {
                  statusChangeCallback(response);
              });
          }
  
          window.fbAsyncInit = function() {
              FB.init({
                  appId      : '284483341757738',
                  cookie     : true,  // enable cookies to allow the server to access
                  // the session
                  xfbml      : true,  // parse social plugins on this page
                  version    : 'v2.0' // use version 2.0
              });
  
              checkLoginState();
  
              FB.Event.subscribe('auth.authResponseChange', function(response) {
                  statusChangeCallback(response);
              });
          };
  
          // Load the SDK asynchronously
          (function(d, s, id) {
              var js, fjs = d.getElementsByTagName(s)[0];
              if (d.getElementById(id)) return;
              js = d.createElement(s); js.id = id;
              js.src = "//connect.facebook.net/en_US/sdk.js";
              fjs.parentNode.insertBefore(js, fjs);
          }(document, 'script', 'facebook-jssdk'));
  
          // Here we run a very simple test of the Graph API after login is
          // successful.  See statusChangeCallback() for when this call is made.
          function testAPI() {
              console.log('Welcome!  Fetching your information.... ');
              FB.api('/me', function(response) {
                  console.log('Successful login for: ' + response.name);
                  document.getElementById('status').innerHTML =
                      'Thanks for logging in, ' + response.name + '!';
              });
          }
      &lt;/script&gt;
      &lt;fb:login-button scope="public_profile,email,ads_management" onlogin="checkLoginState();"&gt;&lt;/fb:login-button&gt;
      &lt;div id="status"&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>It's time to analyze by parts.</p>
  
  <ol>
  <li><p>A function which checks the facebook state and updates a div depending on if the user is not logged in @ facebook, if is logged in but the app not authorized, or finally if is logged in and authorized the app. The change is reflected in the dom. Such function is <code>statusChangeCallback</code>. Such callback is only called inside <code>checkLoginState</code> so each time the login state is checked, the callback is called.</p></li>
  <li><p>A test api call, with a callback which updates the DOM with the results. The function is called <code>testAPI</code>.</p></li>
  <li><p>The asynchronous load bunch. Once it is loaded, an initial call to <code>checkLoginState</code> is successfully performed.</p></li>
  <li><p>A login button, with an <code>onlogin</code> event. The event calls, again, <code>checkLoginState</code>. This is to reflect the new login state in the dom.</p></li>
  </ol>
  
  <p>My issue: <strong>onlogin event is not being triggered</strong>. Everything else works fine. <strong>If I update the page</strong> after logging in (facebook displays a login pop-up), I see the expected state (logged in), as a product of calling <code>testAPI</code>, <strong>but that's not reflected until I refresh the page</strong>. There's another way how I note this: after logging in, I should see a console message coming from <code>statusChangeCallback</code>, but such message neither appears, so I conclude such event is never triggered.</p>
  
  <p><strong>Additional notes</strong>: I'm testing my application in localhost (<code>http://localhost</code>). I enabled the localhost domain in my app (at developers.facebook.com), and enabled a "website" platform with base url of <code>http://localhost</code> (<strong>I'm not using this app in a canvas</strong>). The entry point of my site where I test everything is <code>/</code> (an index.html page). However, these messages appear in console:</p>
  
  <pre><code>Uncaught SecurityError: Blocked a frame with origin "http://static.ak.facebook.com" from accessing a frame with origin "http://localhost". Protocols, domains, and ports must match. VM3437:1
  Uncaught SecurityError: Blocked a frame with origin "https://s-static.ak.facebook.com" from accessing a frame with origin "http://localhost".  The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "http". Protocols must match.
   VM3461:1
  Uncaught SecurityError: Blocked a frame with origin "https://www.facebook.com" from accessing a frame with origin "http://localhost".  The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "http". Protocols must match.
   VM3571:1
  Uncaught SecurityError: Blocked a frame with origin "http://static.ak.facebook.com" from accessing a frame with origin "http://localhost". Protocols, domains, and ports must match.      
   VM3627:1
  statusChangeCallback
   (index):9
  Object {authResponse: undefined, status: "unknown"}
   (index):10
  Uncaught SecurityError: Blocked a frame with origin "https://www.facebook.com" from accessing a frame with origin "http://localhost".  The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "http". Protocols must match.
  </code></pre>
  
  <p>So my <strong>questions</strong> are:</p>
  
  <ol>
  <li>Why does the <code>onlogin</code> event not trigger after I log in?</li>
  <li>Are these errors in console related? I'm using Apache. How can I solve them?</li>
  <li>Is there a way -after a Graph API query (i.e. a GET call)- to know whether the user has logged out?</li>
  </ol>