Multiple session on Separate WebViews - Android

懵懂的女人 提交于 2019-12-10 11:57:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!