views:

65

answers:

3

Hi all, I'm trying to avoid that when a user has connected to Facebook from my webview, the next time he do it, doesn't need to put the email and password. I'm getting the cookie from the "facebook.com" domain with this sentence:

String cookie = CookieManager.getInstance().getCookie("facebook.com");

and storing it in a SQLite database. When the user try to connect another time to Facebook, I use this sentence after removing all another cookies:

CookieManager.getInstance().setCookie("facebook.com", user_acc.getSessionCookie());

but doesn't work. That cookie I suppose that is not valid because the user has to put his username and his password again and after login, I get a different cookie that the one I had stored.

What I'm doing wrong? Is there another way to accomplish that?

Thank you in advance.

+1  A: 

I think you can't do this via cookie because this cookie is valid for only that session and as soon as user logout that cookie expires though you are storing that cookie in your database for facebook that cookie was never created that is why it is asking user name pwd again. I think best way is to click remember password

Parry
There are dozen or so cookies that facebook sets and only one is session cookie.
Peter Knego
So, there is a way to avoid that the user has to login each time that he uses my application? If I don't remove the cookies, he only has to login the first time, so I thought that that information was stored as a cookie because if I remove them, it doesn't occurs.
Adrian
but how will you prevent your user for not hitting logout? because as soon as user click logout the session becomes invalid so u cant achieve what you want by storing cookie in database see this post for session hijacking http://atenlabs.com/blog/how-to-steal-facebook-authentication-cookies/
Parry
I'm programming a Facebook client and the webview only is used to retrieve the access token from Facebook, after that, the logout method I implement in my client wouldn't delete the cookies. Although the user could logout (or delete the cookie) it doesn't matter, when he would want login again the login page of Facebook would appear. I want to store the cookie to make the second and next login times faster.
Adrian