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

iOS cookies not persistent after app exit and restart unlike Android #509

Open
3 tasks done
narayanncube opened this issue Jul 20, 2019 · 10 comments
Open
3 tasks done

Comments

@narayanncube
Copy link

narayanncube commented Jul 20, 2019

Bug Report

Problem

In iOS cookies are not persistent once app is exited and restarted. This creates problem with hosted web app saving cookies or local storage.

On Android it works

What is expected to happen?

It should save cookies and local storage on IOS

What does actually happen?

It doesn't save cookies and local storage.

Information

Command or Code

var ref = cordova.InAppBrowser.open('http://www.syncaridebeta.com', '_blank', 'location=no,toolbar=no,usewkwebview=yes,clearcache=no,clearsessioncache=no,cleardata=no,disallowoverscroll=yes');

Environment, Platform, Device

Version information

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@janpio
Copy link
Member

janpio commented Jul 20, 2019

Could you please confirm if this is also the case when using usewkwebview=no?

@narayanncube
Copy link
Author

Could you please confirm if this is also the case when using usewkwebview=no?

Yes. Its the case. Just tried with both options. Tried following ionic-team/cordova-plugin-ionic-webview#22 for any solution and specifically tried this https://github.com/CWBudde/cordova-plugin-wkwebview-inject-cookie but without any success. May be i was placing in code in wrong place or namespace is wrong or may be ionic thats why

@janpio
Copy link
Member

janpio commented Jul 20, 2019

Is this reproducible in a new, plain Cordova app? A minimal reproduction repository would really help to debug and later fix this issue. More information on how to create one: https://github.com/apache/cordova-contribute/blob/master/create-reproduction.md

@michaellavender
Copy link

michaellavender commented Aug 27, 2019

I also am encountering this issue and have tested with both usewkwebview=yes and usewkwebview=no. If necessary I can create a test application, but it may take some time. I'm using _blank target, as in example above, and am unclear whether it's necessary to use _self target in order to have cookies work, though this doesn't appear to be the case based on the documentation. narayanncube, could you please let me know if you're still running into this issue?

NOTE: This is not an issue for us -- in further testing it became clear that the relevant cookies were "session" cookies, so natually weren't persisted across separate instances of running the app. Once those response cookies were set to have an explicit, future-dated expirations the inappbrowser worked perfectly. My bad. PEBKAC.

@alebupal
Copy link

Any solution? I have the same problem.

1 similar comment
@BradCB
Copy link

BradCB commented Nov 6, 2019

Any solution? I have the same problem.

@michaellavender
Copy link

Per my comment above, this actually was a problem with how we were creating the cookies server-side. They were being created as session cookes (without an expiration date), so would expire as soon as the app was closed because each instance of the app creates a separate inappbrowser instance. By setting an explicit expiration date on the cookie returned by the server this causes the browser to treat it as persistent, rather than for just a single session, and it's there for subsequent instances of the app. In our case we have no need for the cookie to ever expire so we're setting it to have a 12/31/9999 expiration when returned in the response from the server.

@jorgedelcampo
Copy link

Hi, how do you resolved this? I'm trying to start session or set cookies but i can't with Phonegap. If i try from server with any browser session set ok.

@D3VL-Jack
Copy link

@michaellavender
While I'm not using Cordova, I had the exact same issue using WKWebView in swift. Honestly, I tried everything and then saw your comment, I can't thank you enough! It's such a stupid issue, I know of no other implementations that treat a cookie without expiration like this!
Of course, the only one that would, would be Apple 🙄

@batmanbury
Copy link

Yes. Its the case. Just tried with both options. Tried following ionic-team/cordova-plugin-ionic-webview#22 for any solution and specifically tried this https://github.com/CWBudde/cordova-plugin-wkwebview-inject-cookie but without any success. May be i was placing in code in wrong place or namespace is wrong or may be ionic thats why

@narayanncube Did you find a way to explicitly set the cookie expiration? I'm trying to find how I might do the same. I'm currently using the same plugin you mentioned to inject a cookie, so I'm trying to find how to either update this inject-cookie plugin to set the expiration there, or to just get rid of the plugin, and inject the cookie manually and set the expiration myself...

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

No branches or pull requests

8 participants