title: Facebook jQuery Logout using Logout URL and Access Token
body: <p>When a user logs out of my site, unless they also log out of their Facebook account, they remain logged in to my site.</p>
  
  <p>I'd like to comply with point 6 of this policy, so how can I log my users out of my site and out of their Facebook accounts for security <a href="https://developers.facebook.com/policy/" rel="nofollow">https://developers.facebook.com/policy/</a> </p>
  
  <p>I have the following code bound to my login button and it's not working - the user is still logged in to FB after clicking. My console shows that the var accessToken is not defined but I'm not sure why. I'm sure I'm doing something fundamentally wrong, would really appreciate some help!</p>
  
  <pre><code>&lt;script src="http://connect.facebook.net/en_US/all.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
   $(document).ready(function(){
  
    $(".logout").click(function () {
     FB.init({appId : &lt;?php echo $this-&gt;config-&gt;item('facebook_appid');?&gt;,
       status : true,
       cookie : true,
       oauth : true,
       frictionlessRequests: true});
  
     FB.login(function(response) {
       if (response.authResponse) {
       console.log(response.authResponse.accessToken);
       var accessToken = response.authResponse.accessToken;
       }
       });
  
     window.location.replace("https://www.facebook.com/logout.php?confirm=1&amp;next=http://www.mysite.com&amp;access_token="+accessToken+"");
  
  });
  });
    &lt;/script&gt;
  
  &lt;div id="fb-root"&gt;&lt;/div&gt;
  </code></pre>