0

I have a cordova app running on ios platform . The login ID and Password are being passed from the cordova side to the native side and the urls are being called . They are stored in the local storage .whenever Im logging out how do i delete the app data containing the login id and password .

1 Answers1

0

you can use removeItem() for removing the credentials whenever users log out.

In your case it could be -

localStorage.removeItem("loginID");
localStorage.removeItem("password"); //Its not preferred to store passwords in localStorage. Not directly atleast.

UPDATE -

you can do clear() to remove the localStorage completely. just do -

localStorage.clear();

This is simple and efficient. You don't need any other native code to access and remove them explicitly.

If you want to remove items specifically (e.g. password) then you can use a loop to run through all elements and remove them like this -

function cleanLocalStorage() {
  for(key in localStorage) {
      if(key=="password" || key=="something") //optional condition..
         delete localStorage[key];
  }
}

See this answer for the path of LocalStorage Storage locations in the system - https://stackoverflow.com/a/27612275/5213405

pro_cheats
  • 1,534
  • 1
  • 15
  • 25
  • Is there any way i can find out the local storage path and write the code to remove it programmatically from the native side i.e,in objective C code (or swift). – Abhishek V Jul 07 '17 at 10:00
  • see updates in the answer. Hope this helps. :) @AbhishekV – pro_cheats Jul 07 '17 at 11:51