title: Extracting user id from Facebook Javascript SDK session object
body: <p>I am using Facebook's Javascript SDK "FB.ui" to pull up an OAuth dialog. Once you click allow, I need to capture the session object, extract the user id and use it further in my script. For some reason I cannot get this working properly, I keep getting undefined, even though the session does exist.</p>
  
  <pre><code>&lt;script src="http://connect.facebook.net/en_US/all.js"&gt;&lt;/script&gt;
  &lt;div id="fb-root"&gt;&lt;/div&gt;
  &lt;script type="text/javascript"&gt;
  FB.init({
      appId  : '***************',
      status : true,
      cookie : true,
      xfbml  : true
  });
  FB.getLoginStatus(function(response) {
      if (response.session) {
          //do something
      } else {
          FB.ui({
              method: 'oauth',
              display: 'page',
              scope: 'email',
              perms: 'email'
          },
          function(response) {
              alert(response.session.uid); //returns underfined
          });
      }
  });
  &lt;/script&gt;
  </code></pre>