Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing user's Facebook session in Webview

I have a WebView which allows a user to share an image to facebook. This process involves them logging into FB. After they're done I destroy the WebView and the app resets and a different user is offered the same functionality. The intention is for the WebView to not to remain logged in from one session to the next, however, I'm unclear on how to either manually log the user out at the end of their session (calling http://www.facebook.com/logout.php no longer works, apparently), and grabbing new instances of WebView and WebChromeClient doesn't do it either.

However, I notice that when I reinstall the application (as I modify it) the log in is cleared, so, I'm assuming that *somehow Webkit can tell that this is a different app (as it is uninstalled and re-installed) and I'm hoping I can leverage this (or any other) mechanism to clear whatever it is that holds the user's login info... I'm guessing it's a cookie, but I'm not entirely certain that it is.

I'm sure I'm not the first person to need to log the user out of FB manually, but not via my own oAuth (since I'm not the one logging them in).

like image 509
Yevgeny Simkin Avatar asked Aug 23 '11 19:08

Yevgeny Simkin


1 Answers

It's set by cookie. Prior to API 21 use:

android.webkit.CookieManager.getInstance().removeAllCookie();

now this method has been replaced with removeAllCookies which is basically the same but asynchronous with a callback.

like image 83
kabuko Avatar answered Oct 04 '22 21:10

kabuko