0

In our app, click links call webview. so, i need to transfer some data to webview. I think 'cookie' will be help us. but i can't find good guide.

App can create cookie for webview? if possible, it can contain all type of datas? or limited?

I don't know web well. please help me!

P.S. I don't know ios, too. it's policy is same to android?

Redwings
  • 540
  • 2
  • 4
  • 12

1 Answers1

0

1)If you have cookies then you can insert cookies into your webview.

CookieManager cookieManager = CookieManager.getInstance();
 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                cookieManager.setAcceptThirdPartyCookies(webView, true);
            } else {
                cookieManager.setAcceptCookie(true);
            }
            for (String parse : cookie.split(";")) {
                //  System.out.println("==parse== "+parse);
                cookieManager.setCookie("your_url.com"), parse);
            }
Map<String, String> abc = new HashMap<String, String>();
            abc.put("Cookie", cookie);
webView.loadUrl("your_url.com", abc);

2)App cannot create cookies for webview. but webview can create cookies for your App.

String cookies = cookieManager.getCookie("your_url.com");
System.out.println("==cookie== "+cookies);

I think it will help to understand the web & cookies concept. If you have query just let me know.

Tushar Lathiya
  • 940
  • 9
  • 26
  • You mean, app can't create cookie from nothing. but if cookie already exist, then app can insert data to cookie and return it? Am i understanding right? – Redwings Jun 23 '21 at 14:42
  • Yes, you can't create cookie from nothing – Tushar Lathiya Jun 24 '21 at 04:24
  • thanks! And, can i see documentation of cookies? I don't know limit of it. Cookie can contain just string? or every objects, such as dictionary and list? – Redwings Jun 24 '21 at 05:29