开发者

FB.Connect.logoutAndRedirect(''account/logout') will not redirect, even with proper session

开发者 https://www.devze.com 2022-12-21 07:04 出处:网络
My init line: <script type=\"text/javascript\">function initFB(){FB_RequireFeatures([\"XFBML\"], function(){FB.init(\"xxxx\", \"xd_receiver.htm\");});}</script>

My init line:

<script type="text/javascript">function initFB(){FB_RequireFeatures(["XFBML"], function(){FB.init("xxxx", "xd_receiver.htm");});}</script>

My logout link:

<a onclick="FB.Connect.logoutAndRedirect('account/logout');">Log Out</a>

I have a valid session in my webapp, and a valid Facebook session, because my user display pic shows.

The only way that I can get Facebook to log out properly with either this function or .logout() is to throw a

return false开发者_如何转开发;

into the mix, as so:

<a onclick="FB.Connect.logoutAndRedirect('account/logout'); return false;">Log Out</a>

This, however, still does not redirect anywhere. App just sits there after logging out of Facebook, so site session still live, and broken.

This thing is bloody frustrating, so if anyone can make suggestions as to why this will not redirect, I am all ears.


I believe you have to do return false to prevent the normal behavior of a link. As for the redirect, I do this on my site:

<a href="#" onclick="FB.Connect.logout(function() { window.location='account/logout' }); return false;" >Logout</a>

I'm not exactly sure why your logoutAndRedirect does not work though, this post might shed some light: http://forum.developers.facebook.com/viewtopic.php?id=38549.


Located a function that someone wrote to run a Facebook logout and redirect properly. This works perfectly.

Javascript code:
function fBlogout(){
    try{
        FB.Connect.ifUserConnected(function(){
            FB.Connect.logoutAndRedirect('http://fullurl.com/account/logout');
        }, 'http://fullurl.com/account/logout');
    }catch(e){
        location.href = 'http://fullurl.com/account/logout';
    }
}

HTML Link:
<a href="#" onclick="FBlogout(); return false;">Log Out</a>

PHP code for logout:
$facebook->expire_session();
$facebook->logout(MAIN_SITE_URL);
0

精彩评论

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