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

Cookies lost on Android after app restart #611

Closed
kfrederix opened this issue Sep 9, 2020 · 2 comments
Closed

Cookies lost on Android after app restart #611

kfrederix opened this issue Sep 9, 2020 · 2 comments

Comments

@kfrederix
Copy link

We are having a strange issue on Android, with Ionic 5: it seems like most of the time (not always) our session cookies "disappear" after the app is restarted.

We have tested and observed this behaviour on several different android devices, so it's not device-specific. Also (as said above, it does work sometimes, which is especially strange...)

To make sure it's not caused by any other plugins, I have started a new blank Ionic 5 app with cordova. Then added only a little bit of code to:

  • authenticate by http request to /auth endpoint --> sets sessions cookies from response
  • fetch some data by calling an endpoint with withCredentials: true

Observed behaviour:

  1. install app
  2. launch app
  3. authenticate (session cookies get attached to domain with Max-Age properly set)
  4. fetch data (withCredentials: true) --> SUCCESS
  5. can make authenticated calls all day long... works every time
  6. close app
  7. launch app again
  8. fetch data (withCredentials: true) --> FAILS, because session cookies were missing

Version info:

  • Ionic 5.3.2
  • cordova-android: 9.0.0
  • cordova-plugin-ionic-webview: 5.0.0 (also tested with 4.2.1 --> seems to make no difference)

I could upload a "clean" project which can be used for testing/debugging if that helps...

@kfrederix
Copy link
Author

I have figured out the problem: it seems there is a 30 second timer on the sync process between WebView and CookieManager on android. We can solve this by manually flushing the CookieManager on android level.
Solution can be found here: apache/cordova-android#802 (comment).

Closing this issue.

@signalpoint
Copy link

@kfrederix That is bizarre! Same thing observed over here with just plain old Cordova. Thank you.

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

No branches or pull requests

2 participants