问题
I would want to log into two separate Gmail accounts within the two webViews at the same time.
The problem I am having is that once I log into an account on webView1, webView2 follows suit and logs me into that account. The same problem happens when I log into webView2, as webView1 logs into that account also naturally.
Is there any way to get around this? I want my two webViews to act completely independently from one another is what it comes down to.
Thanks!
Here is a code
String Cookies0; String Cookies1;
private void displayView(int webViewSelected) {
if(webViewSelected==0){ Cookies1 = CookieManager.getInstance().getCookie("www.gmail.com"); CookieManager.getInstance().removeSessionCookie(); CookieManager.getInstance().removeAllCookie(); CookieManager.getInstance().setCookie("www.gmail.com",Cookies0); }else if(webViewSelected==1){ Cookies0 = CookieManager.getInstance().getCookie("www.gmail.com"); CookieManager.getInstance().removeSessionCookie(); CookieManager.getInstance().removeAllCookie(); CookieManager.getInstance().setCookie("www.gmail.com",Cookies1); }
There problem here is CookieManager is singleton object and i want to have two instance of it. To do so i am coping the cookies into string and then set it back.
But it is not doing for session.
CookieManager.getInstance().removeSessionCookie();
Above line remove the session. but i want to preserve the session.
来源:https://stackoverflow.com/questions/27054559/multiple-session-on-separate-webviews-android