I\'m loading a website in Webview which uses some cookies to store session. I\'ve written following lines to accept cookies
CookieSyncManager.createInstance(
If you want to pass your login users data to a cookie in Webview the do it like this The other day I had to pass my login object to particular URL as follow.
WebSettings settings = webViewRoi.getSettings();
settings.setDomStorageEnabled(true);
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(false);
settings.setAppCacheEnabled(true);
settings.setAllowUniversalAccessFromFileURLs(true);
settings.setAllowFileAccessFromFileURLs(true);
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
FormsDTO formsDTO = new FormsDTO();
FormsDTOProfile dtoProfile = new FormsDTOProfile(LoginActivity.loginInfoDTO.getProfile());
formsDTO.setProfile(dtoProfile);
formsDTO.setAuthorized(true);
formsDTO.setToken(LoginActivity.loginInfoDTO.getToken());
String out123 = gson.toJson(formsDTO);
String auth2 = URLEncoder.encode(out123, "UTF-8");
String z = "userInfo=" + auth2; // here userinfo is the key of cookie
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
cookieManager.setCookie(url, z);
webViewRoi.setWebChromeClient(new WebChromeClient());
webViewRoi.loadUrl(url);
So if you know the key name of cookie then you can pass your login object through cookie. hope it helps you.