title: facebook login in a cross-domain iframe
body: <p>Note the following 3 files. If all are in the same domain, everything works fine. However, if the parent file is on a different domain, then the facebook cookie does not seem to pass between the two son iframes. I need it to work that way... any advice?</p>
  
  <p>File <em>zzzfbparent.html</em></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;body&gt;
      &lt;iframe src="&lt;domain and directory&gt;/zzzfb1.html" style="width:400px; height:200px;"&gt;&lt;/iframe&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>File <em>zzzfb1.html</em></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;body&gt;
      &lt;div id="fb-root"&gt;&lt;/div&gt;
      &lt;input type="button" value="Login" onClick="doLogin();"&gt;&lt;/input&gt;
      &lt;script&gt;
        window.fbAsyncInit = function() {
          FB.init({
            appId: 'XXXXXXXXXXXXXXXX',
            status: false,
            cookie: true,
            xfbml: false
          });
        };
        (function(){
          if (document.getElementById('facebook-jssdk')) {return;}
          var fjs = document.getElementsByTagName('script')[0];
          var js = document.createElement('script');
          js.id = 'facebook-jssdk';
          js.src = '//connect.facebook.net/he_IL/all.js';
          fjs.parentNode.insertBefore(js, fjs);
        }());
        function doLogin() {
          FB.login(function(respLogin) {
            location.replace('zzzfb2.php');
          }, {scope: 'email'});
        }
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>File <em>zzzfb2.php</em></p>
  
  <pre><code>&lt;?php
  require 'facebook.php';
  $facebook = new Facebook(array(
    'appId'  =&gt; 'XXXXXXXXXXXXXXXX',
    'secret' =&gt; 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  ));
  $user = $facebook-&gt;getUser();
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;body&gt;
      &lt;?php echo '$user='.$user ?&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>