开发者

Log out of BOTH Wordpress & Facebook

开发者 https://www.devze.com 2022-12-22 07:39 出处:网络
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

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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号