Search code examples
androidcookieswebviewinternal-storage

How can I save cookies in internal storage and reuse them?


I've created an Android App with Web View that displays a web-site. Users have to login and my cookies lasts for 8 hours. I need to store the cookies into internal storage and then use that stored data to load the cookies again every time I start the app. Can someone help me ? I've checked lots of questions but I can't figure this out, I really need a code example for that. Thanks !


Solution

  • A CookieStore object represents a storage for cookie. Can store and retrieve cookies.

    CookieManager will call CookieStore.add to save cookies for every incoming HTTP response, and call CookieStore.get to retrieve cookie for every outgoing HTTP request. A CookieStore is responsible for removing HttpCookie instances which have expired.

    further information Click Hear: https://developer.android.com/reference/java/net/CookieStore.html