title: How to test If I am logged into facebook from out of it?
body: <p>I have this facebook login code </p>
  
  <pre><code> $app_id = "xxxxxxxxxxxxxx";
     $app_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
     $my_url = "http://xxxxxxxxxxxxx";
  
  
     $code = $_REQUEST["code"];
  
     if(empty($code)) {
       $_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection
       $dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" 
         . $app_id . "&amp;redirect_uri=" . urlencode($my_url) . "&amp;state="
         . $_SESSION['state'];
  
       echo("&lt;script&gt; top.location.href='" . $dialog_url . "'&lt;/script&gt;");
       print_r( $dialog_url);
  die();
     }
  
     if($_REQUEST['state'] == $_SESSION['state']) {
       $token_url = "https://graph.facebook.com/oauth/access_token?"
         . "client_id=" . $app_id . "&amp;redirect_uri=" . urlencode($my_url)
         . "&amp;client_secret=" . $app_secret . "&amp;code=" . $code;
  
       $response = file_get_contents($token_url);
       $params = null;
       parse_str($response, $params);
  
       $graph_url = "https://graph.facebook.com/me?access_token=" 
         . $params['access_token'];
  
       $user = json_decode(file_get_contents($graph_url));
       echo("Hello " . $user-&gt;name ."&lt;a href=event.php?app_id=".$app_id."&amp;app_secret=".$app_secret."&amp;code=".$code."&amp;access_token=".$response."&gt; Create Event&lt;/a&gt;");
     }
     else {
       echo("The state does not match. You may be a victim of CSRF.");
     }
  </code></pre>
  
  <p>can I test if I am already connected to facebook website, consider it login to this page ? and no login link is being displayed ?</p>