When I logout from my site using FB connect, Facebook account also logged out. I need a alternate logout option, so that only fb session of my site destroyed, not from the a开发者_运维百科ctual fb site.
Unfortunately, this is the behavior that Facebook calls for: FB.logout API Reference
I think the idea is that most people will stay logged in to Facebook, and so will automatically be logged in to all the FB connect sites they go to as well (after granting permission to those sites), so that they don't have to worry about logging in. Then, if it's a public computer or they need to logout of one site, FB makes sure they log out of them all.
If you want different semantics, you could always provide a logout button that instead of calling FB.logout, just marks their session as no longer connected (delete the appropriate cookies, change whatever you need to server side), but I'd just stick with the default behavior (many sites show a popup saying that you'll be logged out of FB as well).
You also have to clear the sessions and cookies created by facebook with the following:
using Facebook;
Thread.Sleep(1000); // delay is required to get it work
Facebook.Session.ConnectSession cn = new Facebook.Session.ConnectSession(ConfigurationManager.AppSettings["APIKey"].ToString(), ConfigurationManager.AppSettings["Secret"].ToString());
cn.Logout();
精彩评论