views:

93

answers:

2

Hi All,

So I've successfully integrated Facebook into my Wordpress site. I've also linked together the accounts. However, the way the site works is that you're either logged into the site via the

  1. Wordpress Account
  2. Facebook Account or
  3. Wordpress & Facebook

I know how to log out of Facebook and I know how to log out of Wordpress, but the two methods are using Javascript and PHP respectively.

How would I, with one logout link, use both the PHP and Javascript logout methods?

+1  A: 

I would use Ajax. You can call the javascript function and a php script. If you have no idea how ajax works a really easy way to do is using jQuery.post.

gabriele
or jQuery Get, if you were about to write some custom code to do it.
Chacha102
+2  A: 

I solved this issue by using FB.Connect.logoutAndRedirect()

<a href="#" onclick="FB.Connect.logoutAndRedirect('/fb_logout.php')">Sign out</a>

and in fb_logout.php I used: session_destroy(); like:

<?php 
session_destroy();
header('Location: http://yoursite.com');

Which seems to work pretty well.

Jayrox