Clear Phonegap's InAppBrowser Cache Programmatically

benjipelletier picture benjipelletier · Dec 3, 2014 · Viewed 16.1k times · Source

I am using Oauth 2.0 for Google authorization into a hybrid app. I am using PhoneGap's InAppBrowser API and it works perfectly; however, I want to be able to clear the cache of the InAppBrowser after someone clicks the local logout button. I have tried adding "clearcache=yes" and "clearsessioncache=yes", but they do not seem to do anything. Without clearing the cache when someone tries to log back in it validates the token with the previously signed in account. The only way I can sign out is to keep trying to login until I get the Google permissions screen and can manually logout. Is there a way I can delete everything associated to the InAppBrowser programmatically?

Thanks

Answer

AAhad picture AAhad · Dec 3, 2014

As said: clearcache or clearsessioncache is only for Android. read this API Doc

In case of Android so before re-opening:

window.open("domain.com", "_blank", "location=no,clearsessioncache=yes"); 

For iOS: check this out.

Alternatives:

  1. Clear the session cookie via javascript directly or indirectly (check this - JQuery Cookie clearing )
  2. Phonegap/Cordova plugin that allows you to clear cookies of the webview...see this