I have an Android app (and hopefully later an iPhone) based on Javacript and made in the app using Phonegap / Applaud.
Unfortunately, setting and receiving cookies does not work on Android, and this may be especially true for the Android environment. I was told that using "local storage" could be more reliable.
However, I did not know anything about the local repository until this morning, and therefore I am struggling to understand. From what I'm compiling, this is basically just a place to save data with a different syntax. For my situation, I donβt think it gives me any advantages over cookies, except that Android forces me to use it. As a result, I hope that I can still use my existing code to set up and receive cookies and should not take a completely new approach.
Of course, I can just run a test in my Javascript to find out if there is local storage, and if so, save and load my cookie data, and if not, just use cookies as usual?
Note 1: I searched Qaru for similar questions, and there was this one that at first seems to be exactly what I'm talking about , but it is too short, so I can not parse it to know what to do with it. In addition, I think that it assumes the existence of libraries and code, which I think I donβt have. I also looked at this question , but I think that it does the opposite of what I need.
Note 2: This is my current code for receiving and setting cookies (purchased somewhere on the Internet. Until the Android issue was reliable):
function getCookie(c_name) { var c_start = document.cookie.indexOf(c_name + "="); if (document.cookie.length > 0) { if (c_start !== -1) { return getCookieSubstring(c_start, c_name); } } return ""; } function setCookie(c_name, value, expiredays) { var exdate = new Date(); exdate.setDate(exdate.getDate() + expiredays); document.cookie = c_name + "=" + escape(value) + ((expiredays === null) ? "" : ";expires=" + exdate.toUTCString()); alert("this is document.cookie: " + document.cookie); }