0

I have write cookie in JavaScript

function setCookie(cname,cvalue){
   window.localStorage.setItem(cname, JSON.stringify(cvalue));
}

setCookie('test_cookie',123);


function getCookie(cname) {
    var cookieValue = window.localStorage.getItem(cname);
    if (cookieValue) {
        return JSON.parse(cookieValue);
    } else {
        return "";
    }
}

getCookie('test_cookie'); //Output 123

I have generate one cookie name is test_cookie and value is 123 I need to get this 123 cookie value in Java code.

How to get my cookie value in Android Java?

Chinmay235
  • 3,236
  • 8
  • 62
  • 93

2 Answers2

0

This question might answer your problems.

Communication between Android Java and Phonegap Javascript?

You'll need to add a JavascriptInterface.

Community
  • 1
  • 1
0

you can find your answer here-

yourWebViewVariable.getSettings().setJavaScriptEnabled(true);

for Android 3.1 just add this to your java file onLoadInit:

CookieManager.setAcceptFileSchemeCookies(true); //This is the line that    
specifically makes it work so the other lines is optional

CookieManager cookieManager = CookieManager.getInstance();      
cookieManager.setAcceptCookie(true); cookieManager.acceptCookie();
Community
  • 1
  • 1
RajSharma
  • 1,941
  • 3
  • 21
  • 34