Noah
Noah

Reputation: 141

What is the proper approach to store cookies or sessions in android app?

I'm sorry in advance if this question is not good enough to be asked, But i made a lot of search to get the proper approach to store cookies in my android app which makes a lot of web connections.

I found more approaches deals with storing cookies in android app, But i can't determine what is the proper one, Or when i should use one rather than others !!

I'll write some of what i found not all:-

The most two things i consider about cookies storing are security and long-lived age of cookie.

Upvotes: 2

Views: 976

Answers (1)

Kirill Popov
Kirill Popov

Reputation: 320

It depends on how you want to use them:

  1. Only SharedPrferences approcach allows persistent cookie storage. For example if you do not want user perform login every time he runs your app.
  2. CookieManager is used internaly by WebView. It keeps cookies in

    class InMemoryCookieStore implements CookieStore
    

so it is not persistent.

  1. HttpCookie is used by HttpClient. It is just cookie representation and it doesn't responsible for their storage.

Upvotes: 2

Related Questions