4

first of all, can someone please explain how does CookieManager.getInstance() work? I don't really get how I can get the session from webview? Lets say if I have this

CookieSyncManager.createInstance(WebviewPage.this);
CookieManager cookieManager = CookieManager.getInstance();

Do I get the session from the class named WebviewPage? but what if I named my actual WebView to webview, how can cookieManager get the session of webview? not even talk about if I had two WebView, webview1 and webview2. How do I know which session that was stored in cookieManager??

My main question is...I have two activities and one webview in each activity. How can I get the session from Activity A and pass it to the webview in Activity B?

Thanks!!!

user1865027
  • 3,505
  • 6
  • 33
  • 71

2 Answers2

1

As far as I know, you don't need to set cookie for webview2. webview2 will automatically use the cookies from webview1.

gZerone
  • 673
  • 12
  • 28
0

CookieManager seems to be a singleton, so when you call getInstance() you always get the same instance. So if webview 1 set some cookies on the CookieManager, or if you set it your self using set Cookie, all other webviews should get the same cookies as well.

elvitucho
  • 126
  • 6