cordova-plugin-cookies
This plugin returns the cookies from the webview for a specific url so the cookies can be used e.g. to get the cookies from cordova-plugin-inappbrowser and pass it to cordova-plugin-advanced-http.
Installation
cordova plugin add cordova-plugin-cookies
Supported Platforms
Limitations
It doen't work with the UIWebView on iOS (It's deprecated by Apple).
Usage
Plain
window.cordova.plugins.CookiesPlugin.getCookie(url, (cookies) => {
console.log(url, cookies);
});
Extended
const iab = this.inAppBrowser.create(url, "_blank");
iab.on("loadstop").subscribe(() => {
(window as any).cordova.plugins.CookiesPlugin.getCookie(
url,
async (cookies: string) => {
cookies.split(";").forEach((cookie) => {
this.http.setCookie(sapSettings.url, cookie);
});
if (await this.isUserAuthenticated()) {
iab.close();
}
}
);
});