FB.getLoginStatus returns unknown status

I am trying to implement Facebook automatic login, I used the following code as indicated in the facebook docs. When I click on the "Login" link, it shows the status as "connected", but after that, if I close my browser window without leaving it and launching my project on the local host again, it will display the login status as "unkown"instead "connected".

Is there any additional code I need to put together?

<html xmlns="http://www.w3.org/1999/xhtml">
  <head runat="server">
    <title></title>
  </head>
  <body>
    <form id="form1" runat="server">
      <div>
        <div id="fb-root"></div>

        <script type="text/javascript">
          //var fb_deferred = $.Deferred();
          //var MMF;
          window.fbAsyncInit = function () {
            FB.init({
              appId: myappid,
              channelUrl: "//localhost/channel.html",
              status: true,
              cookie: true,
              xfbml: true,
              oauth:true
            });

          FB.getLoginStatus(function (response) {
            document.getElementById("At").innerHTML = response.authResponse.accessToken;

            if (response.status === 'connected') {
              alert("connected");
            } else if (response.status === 'not_authorized') {
              alert("not_authorized");
            } else {
              alert("not_logged in");
            }
          }, true);
        };

          (function (d) {
            var js, id = 'facebook-jssdk'; if (d.getElementById(id)) { return; }
            js = d.createElement('script'); js.id = id; js.async = true;
            js.src = "//connect.facebook.net/en_US/all.js";
            d.getElementsByTagName('head')[0].appendChild(js);
          }(document));
        </script>
        <a style="margin-bottom: 5px;" href="https://www.facebook.com/dialog/oauth/?state=2ea08f58-d785-4358-9db3-5154a4431222&amp;scope=email,user_birthday,publish_actions&amp;redirect_uri=http://localhost/&amp;client_id=myappid" data-submission-style="once">Log in with Facebook</a>
        <div id="At"></div>
      </div>
    </form>
  </body>
</html>
+4
source share