Issue
All WebViews of an Android app share (among other data) their set of stored cookies. I want to separate the cookie storage, i.e., every WebView should have their own set of cookies.
Therefore, I am looking for a way to retrieve all cookies including meta-information (Expire date, flags etc.) from a WebView, save them separately and set them again when needed. CookieManager
has a method getCookie()
, however, it just returns value and name of currently valid cookies without any meta info (as discussed here).
Android WebView stores cookies in an SQLite3 database on disk. Apparently, the only way to gain the full cookie information is to have a look at the on-disk cookie store. It would be possible to parse the SQLite3 database and use CookieManager
's setCookie()
but then all encrypted values would be lost. So my idea was to copy the whole database file and exchange (i.e., rename) the file as needed.
Potential problems of this approach:
- Synchronization issues: I don't have access to any locks the system may use for access to the cookie file.
- Even if I try to rename the file ignoring the first problem, the database is only read upon start of the app. Afterwards, all cookies (both old cookies read from disk and new cookies added during runtime) are kept in RAM. I would need to force a reload from disk, but the API only offers sync in the other direction, i.e., from RAM to disk.
Where can I find the code that loads the cookies from disk initially? Android SDK's CookieManager.java
is an abstract class, where do I find the actual implementation? It may have valuable insights on the issue.
Solution
For reference: A member of the Chromium development team confirmed that it is currently not possible to separate the cookie storage within an app.
Answered By - Calyx
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.