title: FACEBOOK : Find Logged in User Using PHP
body: <p>I use Following php code in my wordpress site</p>
  
  <pre><code>&lt;?php
  session_start();
  
  require 'src/facebook.php';
  include 'config.php'; 
  $facebook = new Facebook(array(
    'appId'  =&gt; $app_id,
    'secret' =&gt; $app_secret
  ));
  
  // Get User ID
  $user = $facebook-&gt;getUser();
  
  if ($user) {
    try {
      $user_profile = $facebook-&gt;api('/me');
    } catch (FacebookApiException $e) {
      error_log($e);
      $user = null;
    }
  }
  
  if ($user) {
  echo "loggedin";
  
  }
  
  else
  {
  echo "not loggedin";
  }
  
  ?&gt;
  </code></pre>
  
  <p>But even when i authenticate my app, I keep on getting <strong>not loggedin</strong> status.
  The above code works fine on normal app, But not in my wordpress site, I get session error, header already sent.</p>
  
  <p>Please anyone tell alternative way to solve this problem.</p>
  
  <p>Note: I dont want javascript</p>