views:

6880

answers:

6

How can I log a user out from my facebook connect website, without using the fb-login button? I would like to do it from codebehind (c#)?

+4  A: 

I found out that there was only an option to do it from Javascript by FB.Connect.logout(). It seems kinda wird that there is no API from codebehind to do the same.

Dofs
moved to FB.logout()
Oduvan
A: 

At least in the php api there is a logout method. In order for it to work the logout method redirects the user to an url in facebook.com and then redirects you back to your site

$facebook->logout( "http://site.com/returnAfterLogout.php" )

However i have found that in that request the javascript api still thinks the php api still thinks he is logged in and until you try to do an api request it will raise an exception.

Mon Villalon
This was a question related to the .Net version of facebook api, and not php.
Dofs
A: 

I hope the developers will use some more time to extend the .net facebook framework so it will reflect the php a bit more, and not be so lacking as it is at the moment.

Dofs
+3  A: 

You can easily do this from an instance of the facebook.API class(facebook.dll). Just call _api.LogOff()

+1  A: 

My painful experience showed me you MUST have a return(false); after the FB.Connect.logout(); call like in :

FB.Connect.logout(doOnUserLogout()); return(false);

Otherwise it'll seem like it is logging out, with the modal dialog box stating so, but it will not log the user out.

I found this out by chance as it was again not documented.

Stephane
I assume you're calling this method from inside a button/link? If that's the case, that's why the "return false" is required. It's not missing in the facebook documentation - if you want to prevent a link/button's default action (ex. the href) from executing, you will need to return false, otherwise it will navigate before your onclick handler finishes.
tlianza
A: 

seems ConnectSession doesn't have any codes in Logout methd. Its just

void Logout(){ }

without anything. same for Login(){}

so basically u will need to use the java-script version

prabir