Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cookie based Authentication on Phonegap

I'm facing a problem with phonegap cookie based authentication: After i force the iPhone to close my app (double click on the physical button and close), i lose the cookie that i established with the server. How can i avoid it? Is there some configuration? Or an alternative way for it?

It works normally when i run it for the first time and the error just happens when i force close the app. It works normally on android.

I'm using: iPhone - iOS 6.1 and Cordova 2.5

Thanks

like image 798
Flavio H. Freitas Avatar asked May 09 '13 13:05

Flavio H. Freitas


1 Answers

I would advice you to abandon cookie solution and instead to switch to localStorage solution.

iOS 6.X has few problems with cookie handling and even if Apple fix all problems some people will still use older version thus making your app unusable on older platforms. Cookies are archaic technology and there are some talks iOS will loose the support in some future versions.

On the other hand localStorage is fully supported on HTML5 browsers.

You can go even further that that. There's a great js framework called persistance.js. It will automatically use best storage option for your device and there are 4 different kinds of storage solution.

like image 61
Gajotres Avatar answered Sep 21 '22 10:09

Gajotres