3

I am using Cordova to wrap my Angular webapp into hybrid app for Android and iOS.

I am using spring security for login and remember me functionality. When a user logs in with remember me, spring automatically creates remember me token and set it on the domain.

In random cases when I re-launch the hybrid app on Android, I see that the token cookie is missing, and I have to login again.

The same code works fine on web browsers.

Jeroen
  • 1,168
  • 1
  • 12
  • 24
Dimitrii
  • 116
  • 2
  • 10
  • 2
    Have you tried to check if the cookie exists on your mobile device? On Android devices you can debug your cordova app with [chrome dev tools](https://developers.google.com/web/tools/chrome-devtools/remote-debugging/?hl=en). Once your debugging your app with chrome dev tools, cookies can be found in Application -> Storage -> Cookies. – Phonolog Oct 18 '16 at 15:16
  • 1
    Duplicated of http://stackoverflow.com/questions/15349237/handling-cookies-in-phonegap-cordova ? – Felipe Sabino Oct 24 '16 at 23:30
  • I ran into the same situation in one of my Cordova Applicaiton, then after searching for long, I found InApp webkit browsers doesn't support cookies and you'll have to go with `localstorage` only to store the data offline for any purpose. Refer this for more info on localstorage in case of cordova - http://cordova.apache.org/docs/en/6.x/cordova/storage/storage.html#page-toc-source – Himanshu Aggarwal Oct 25 '16 at 11:02

1 Answers1

0

Yes, I've experienced this on Android using Cordova. The webkit rendering the HTML and storing all your javascript variables is preserved in memory so long as your app is running either in the foreground or in the background. Once your app is removed from memory then the webkit is rebooted afresh. Its not like your browser. Cookies don't seem to be persistent from reboot to reboot. If you need persistent storage then use 'Storage' or use the cordova file system hooks.

Anton Codes
  • 3,663
  • 1
  • 19
  • 28