title: Facebook Login Doesn't Work
body: <p>I am trying to add Facebook login to my web site.</p>
  
  <p>What I have done?</p>
  
  <ol>
  <li>Created APP on Facebook as <code>Website with Facebook Login</code></li>
  <li>Sandbox mode is <code>off</code></li>
  <li>APP is set to work on <code>localhost</code>.</li>
  </ol>
  
  <p>What is the problem?</p>
  
  <ol>
  <li>I keep getting <code>$user</code> variable's value as <code>0</code></li>
  <li>example.php in Facebook PHP SDK works just fine!</li>
  <li>I can see my APP when I visit <strong>Facebook -> Privacy Settings -> Apps</strong>. No matter if I login with my <code>login.php</code> or <code>example.php</code> of <strong>Facebook PHP SDK</strong>, the app seems to be added just the same. However while <code>example.php</code> can retrieve data from facebook, <code>login.php</code> can't.</li>
  <li>I copy and paste the codes from <code>example.php</code> to my <code>login.php</code> page (please check the code below).</li>
  </ol>
  
  <p>Here is my code (<strong>login.php</strong>);</p>
  
  <pre><code>require_once('system/api/facebook/facebook.php');
  $facebook = new Facebook(array(
    'appId'  =&gt; '123456',
    'secret' =&gt; 'abcde12345',
  ));
  
  $user = $facebook-&gt;getUser();
  
  if ($user) {
    try {
      $user_profile = $facebook-&gt;api('/me');
    } catch (FacebookApiException $e) {
      error_log($e);
      $user = null;
    }
  }
  
  // Login or logout url will be needed depending on current user state.
  if ($user) {
    $logoutUrl = $facebook-&gt;getLogoutUrl();
  } else {
    $loginUrl = $facebook-&gt;getLoginUrl();
  }
  
  if (!$user) echo '&lt;a href="'.$loginUrl.'"&gt;Login&lt;/a&gt;';
  
  echo '&lt;pre&gt;';
  var_dump($user);
  echo '&lt;/pre&gt;';
  </code></pre>
  
  <p>Can someone please tell me what is the difference between my <strong>login.php</strong> and <strong>example.php</strong>? I also Googled and searched here without finding any info which was helpful.</p>