I am going to develop a shopping cart Mobile application using cordova & js,jquery for android & ios and i am really confused where to store the cart data while adding either in cookies or session or local storage etc any suggestion ? and how to maintain a session so that i can implement the autologin for the app ?
-
1you can also prefer [indexeddb](http://blogs.shephertz.com/2014/01/14/html5-learn-how-to-use-indexeddb/) – Narendra Jadhav Aug 09 '17 at 11:57
-
cannot use that indexeddb – Madpop Aug 09 '17 at 12:12
-
I have used Localstorage for shopping cart data where each item# is the key to the item in Localstorage. That has worked well. Above someone mentioned using IndexedDB that will work on both iOS and Android, but you would have to use something like PouchDB (it will use IndexDB on Android and Web SQL or SQLite on iOS) https://pouchdb.com/faq.html I would say stick with Localstorage for a simple cart. – Elim Garak Aug 09 '17 at 18:59
1 Answers
The session
is stored on the server whereas the cookies
is stored on the user desktop.
In the session, you have no way to retrieve the cart's information after the session is expired (generally 30 minutes at most). You will throw away 2 hours of Paula's time, who has struggled to choose that red shirt over the green one.
Cookies's size and number are indeed limited and it would be frustrating to have only half of your cart saved.
Another difference is that some people don't accept cookies. The session solution would work anywhere.
You have two more fair options :
database
: to be able to push emails pushing him to buy the stuff. Or if you wan't the user to access his cart on any device.
localstorage
: which is basically a cookie 2.0. It doesn't work on very old browsers though.
If you don't have special needs, cookies or local storage is a good deal.
as follow as full example and how to store data whith cardova

- 1,436
- 12
- 16
-
-
-
@ betrice mpalanzi i know there are various options just want to know whats are best practices to implement – Madpop Aug 09 '17 at 12:12
-
in link 1 (cardova1) there show disadvantage and advantage of any stored data but you can use LocalStorage if you dont have many total amount of storage – betrice mpalanzi Aug 09 '17 at 18:17