Question

I was able to successfully login to Facebook and get required permissions for my Windows Phone 8 application using the tutorial here -

http://facebooksdk.net/docs/phone/controls/login-ui-control/

Now, the login button control opens up a browser window and asks the user to login.

Then the user logins and grants permissions to my app.

Then the user is redirected back to my app on the phone and sees the login button changed to logout button.

When the user will click on the logout button, the session data is removed from the loginbutton control. So my app sees the user as logged out.

But when the user logs in again, he is not asked for his credentials and is directly logged in to his account - this is because the user actually never logged out of the web browser window in the Windows Phone application.

So how do I logout the user from the browser control in my Windows Phone 8 application.

All help is greatly appreciated!

Was it helpful?

Solution

The user is not asked for his credentials because the Facebook authentication cookie is still present in the WebBrowser control.

So to completely logout the user from Facebook, you need to clear the WebBrowser cookies.

Unfortunately, there is no easy way for erasing cookies on Windows Phone 7.

On Windows Phone 8 you just need to call ClearCookiesAsync:

await new WebBrowser().ClearCookiesAsync();

Here is a tutorial that makes use of it: http://www.developer.nokia.com/Community/Wiki/Integrate_Facebook_to_Your_Windows_Phone_Application

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top