简体   繁体   中英

Can I access a HTTP cookie in my webview natively from Android?

I'm writing a Cordova app and I would like to access its HTTP secure cookie from a plugin. I want to encrypt / disable it until the user enters a valid pin.

All help is greatly appreciated. Thank you.

The way I would do it would be to enable/disable the cookies for the entire application:

CookieManager mCookieManager = CookieManager.getInstance();
CookieSyncManager.createInstance(this);
mCookieManager.setAcceptCookie(false); //disables cookies for the WebView until the user enters a correct pin

if(getUsersPin()) { //getUsersPin() gets the pin from the user
    mCookieManager.setAcceptCookie(true);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM