Home > Enterprise >  How to get document cookies in Ionic Angular
How to get document cookies in Ionic Angular

Time:12-12

The app stores data in cookies after successful login. I need to retrieve the data back for another reason but I am unable to get it with the following JS command.

document.cookie

Is there any way to get the cookie? I tested the app in the desktop browser and can see the cookie stored in the browser's local storage.

I use the Ionic native HTTP plugin. https://ionicframework.com/docs/native/http

CodePudding user response:

I don't have all the information about the cookie here, but if the cookie is HttpOnly it cannot be accessed by javascript.

CodePudding user response:

The HTTP plugin has a method to get the cookie as a string.

The following is an example of how to get the cookie.

this.httpNative.getCookiesString(url);

In the param, need to pass a URL for which we need to retrieve the cookie.

  • Related