title: Facebook-connect gives a redirect loop
body: <p>Please, I need help. I'm dealing with this issue for 1 month!!</p>
  
  <p>I would like to implement facebook connect login to my website, using PHP and php-sdk 3.1.1. In few words, my code works offline (on localhost) but not online which results in "Too many redirect loop (on Chrome)": Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.</p>
  
  <p>Here is my code:</p>
  
  <p>1/ I load facebook connect SDK and init it:</p>
  
  <pre><code>    require 'src/facebook.php';
      $facebook = new Facebook(array(
          'appId'  =&gt; '209633612480053',
          'secret' =&gt; 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
      ));
  </code></pre>
  
  <p>Please, note that I created two apps on facebook-developper page, one for offline tests, and the other for online tests. And I'm sure to switch correctly betwwen the two pairs of appId/secret (online and offline) when testing. So it's not the problem of bad facebbok-connect init.</p>
  
  <p>2/ I try to get user info:</p>
  
  <pre><code>  $uid = $facebook-&gt;getUser();
  
    if($uid)
    {
       /*
        * Get user information.
        */
       $user = $facebook-&gt;api('me/');
       print_r($user); // Display user info.
    }
    else
    {
       /*
        * Redirect to FB login URL to allow access.
        */
       $loginURL = $facebook-&gt;getLoginURL();
       echo '&lt;script&gt; top.location.href=\''.$loginURL.'\'&lt;/script&gt;';
    }
  </code></pre>
  
  <p>It's as simple as that: If user ic connected to facebook, so display it's information, else, redirect to facebook login page to allow access.</p>
  
  <p>IT WORKS PERFECTLY OFFLINE, but online, I get a chrome error:</p>
  
  <pre><code>This webpage has a redirect loop
  The webpage at https://www.facebook.com/dialog/oauth?client_id=209633612480053&amp;redirect_uri=http%3A%2F%2Fwww.bluward.com%2Foauth%2Ffacebook&amp;state=551f60cd4be6cd8ed1622f8168a5219a#_=_ has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.
  </code></pre>
  
  <p>Some additional information: Online, I use 1and1 host provider, and to be sure to have the same server configuration than offline server (which is a MAMP Pro), I uploaded the sams php.ini file.</p>
  
  <p>Please, if someone has an idea, or get a similar problem, I'll be glad to have help.</p>
  
  <p>Thank you in advance for all help.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I updated my code to focus on the problematic line, so instead of redirecting to facebook login page, I display the redirect URL, so I just have to click to login:</p>
  
  <pre><code>  $uid = $facebook-&gt;getUser();
  
    if($uid)
    {
       /*
        * Get user information.
        */
       $user = $facebook-&gt;api('me/');
       print_r($user); // Display user info.
    }
    else
    {
       /*
        * Redirect to FB login URL to allow access.
        */
       $loginURL = $facebook-&gt;getLoginURL();
       echo $loginURL; // &lt;-- HERE I CHANGED THE CODE TO DISPLAY LOGIN URL
    }
  </code></pre>
  
  <p>What I noticed is that facebook is infinitely redirecting to my script page. Only <code>code</code> parameter on URL bar changes.</p>
  
  <p>So, why facebbok is redirecting to my script page without giving me user info?</p>
  
  <p>Please, any idea?</p>