Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CB-6389] add clearsessioncache option to iOS (like Android) #34

Closed
wants to merge 3 commits into from

Conversation

mark-bradshaw
Copy link
Contributor

I'd like to add the clearsessioncache option to iOS that Android has. The feature appears to be rather uncomplicated. If clearsessioncache is turned on, then when a url is open in the appbrowser, before it loads, I clear out all the cookies. This should effectively clear out any session that existed before, allowing for a clean slate.

@jak
Copy link

jak commented Apr 3, 2014

Deleting cookies isn't the same as clearing cache. May I suggest renaming the option to 'clearcookies' for iOS, or better yet, clearing the cache with something like:

[[NSURLCache sharedURLCache] removeAllCachedResponses];

Documentation reference

@clelland
Copy link
Contributor

clelland commented Apr 4, 2014

Umm... you're absolutely right there. And I'm not sure quite how I missed that.

I'll reopen the original issue (CB-3617) since that's clearly not done. The option name should be changed here, and we should start thinking about parity on other platforms.

Two issues to resolve:

  1. Do session cookies get cleared when the InAppBrowser is closed? If so, there's never going to be a need to explicitly clear those ones on a window.open call.
  2. Does sharedURLCache in this case contain cached responses for just the IAB, or for the entire application? (XHRs, internal navigation, etc.) If so, we probably don't want to clear it this way, and should probably just start the InAppBrowser with its own isolated URL cache instead, and clear that cache when requested.

@agrieve
Copy link
Contributor

agrieve commented Apr 4, 2014

Seems like a simple expectation, but AFAIK, all UIWebViews have a shared cache & cookie jar. We could probably clear them out for a whitelist/blacklist of domains though.

@mark-bradshaw
Copy link
Contributor Author

The answer for #1 is no, unfortunately, which is the reason why I want this functionality and why I am clearing cookies. If you close() inappbrowser and open the same url, you get your cookies and your session back intact.

The docs for clearsessioncache (on https://cordova.apache.org/docs/en/3.0.0/cordova_inappbrowser_inappbrowser.md.html) indicate that it clears the session cookie cache on android. So it seems that what we've got now is actually in parity with android. Though I completely agree that the name of the property is a bit misleading. 'clearcookies' does make tons more sense as a name, but I think that we are probably better off just duplicating the android functionality even with a bad name.

In any case, what I really need is to be able to clear cookies, not the cache, so whatever the name ends up being I want to maintain the functionality.

@jak
Copy link

jak commented Apr 4, 2014

That's a very good point. The docs do indeed say it clears cookies.

I'm inclined to agree with @mbradshawabs, and it would make more sense to replicate the functionality and rename the option in a separate change as it would be changing the API.

@mark-bradshaw
Copy link
Contributor Author

I think @jak 's notion makes good sense. We can add new config options for 'clearcookies' and 'clearsessioncookies' that will trigger this functionality. We could note the current config options that reference the cache as deprecated and swing around later and remove them.

@clelland
Copy link
Contributor

clelland commented Apr 7, 2014

Okay, so:

  1. Android docs say that clearcache and clearsessioncache apply to the cookie store.
  2. Android code actually does clear the cookie store.
  3. This patch adds the same feature for iOS, under the same flag names.

So this patch is good, and I"ll leave the issue closed, and update the docs.

We could change the names of the options as another issue, but there are backwards compatibility issues to consider there. We would have to work within the deprecation policy, and I'd be uncomfortable reusing those names for some different functionality.

@PaulMazzuca
Copy link

This doesn't seem to work for clearing state data related to Google OAuth login. I believe Google uses cookies for this however I might be mistaken. Have any of you been able to clear out Google login information with the clearcache and clearsessioncache? I am able to login to Google with the inappbrower and subsequent open calls remember the user, however, now the question becomes how to log a user out. I assume user authentication would be a core usage of inappbrowser usage.

@agrieve
Copy link
Contributor

agrieve commented Jun 27, 2014

bump - what's the state of this?

@mark-bradshaw
Copy link
Contributor Author

It's already been released in the plugin, back in April.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants