title: getLoginStatus javascript facebook disappear when page reload
body: <p>I implement the facebook connect and it works fine. </p>
  
  <p>This function return my name after login.</p>
  
  <pre><code>FB.getLoginStatus(function (response) {
      if (response &amp;&amp; response.status === 'connected') {
           FB.api('/me', function(response) {
              console.log('Good to see you, ' + response.name + '.');
          });
          //console.log('connected');
      } else {
          console.log('not connected with FB');
      }
  });  
  </code></pre>
  
  <p>But, when I reload the page, I recall this function and it returns 'not connected with FB'.</p>
  
  <p>I join my login function to help : </p>
  
  <pre><code>    FB.login(function(response) {
  
      if (response.authResponse){
        //L'utilisateur a autorisé l'application
        //window.location.replace("http://adresse/de/redirection");
      } else {
        //L'utilisateur n'a pas autorisé l'application
      }
    }, {scope: 'public_profile,user_friends,email'});
  </code></pre>
  
  <p>I don't find any solution in facebook documentation</p>
  
  <p>To show the issue, my console log is like this:
  <a href="http://i.stack.imgur.com/1Euhv.png" rel="nofollow">console log with my code</a></p>
  
  <p>EDIT :
  Please find attach my full code. I process from localhost</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Facebook Login JavaScript Example&lt;/title&gt;
  &lt;meta charset="UTF-8"&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;button id="loginBtn"&gt;Facebook Login&lt;/button&gt;
  &lt;div id="response"&gt;&lt;/div&gt;
  
  &lt;/body&gt;
  &lt;script&gt;
  
  function getUserData() {
      FB.api('/me', function(response) {
          document.getElementById('response').innerHTML = 'Hello ' + response.name;
      });
  }
  
  window.fbAsyncInit = function() {
      //SDK loaded, initialize it
      FB.init({
          appId      : 'XXXX',
          xfbml      : true,
          version    : 'v2.2'
      });
  
      //check user session and refresh it
      FB.getLoginStatus(function(response) {
          if (response.status === 'connected') {
              //user is authorized
              document.getElementById('loginBtn').style.display = 'none';
              getUserData();
          } else {
              console.log(response.status);
              //user is not authorized
          }
      });
  };
  
  //load the JavaScript SDK
  (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'));
  
  //add event listener to login button
  document.getElementById('loginBtn').addEventListener('click', function() {
      //do the login
      FB.login(function(response) {
          if (response.authResponse) {
              //user just authorized your app
              document.getElementById('loginBtn').style.display = 'none';
              console.log(response);
              getUserData();
          }
      }, {scope: 'public_profile,user_friends,email', return_scopes: true});
  }, false); 
  &lt;/script&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Thanks for support</p>