I am using Firefox version 32.0 and Chrome version 36.0. I want to use Lawnchair for a client side, persistent json data store. I created an HTML to try it out, as follows:-
<!DOCTYPE html>
<html>
<head>
<title>my osim app</title>
</head>
<body>
<div id="visit-times"/>
<script src="http://brian.io/lawnchair/downloads/lawnchair-0.6.1.min.js"></script>
<script>
var store = new Lawnchair({ name: 'testing' }, function (store) {
store.get('counter', function (cnt) {
if (!cnt) {
cnt = { key: 'counter', val: 1 }
}
else {
cnt.val++;
}
store.save(cnt);
document.getElementById("visit-times").textContent = "You visited this page " + cnt.val + " times.";
});
});
</script>
</body>
</html>
When I am opening this HTML file (located on IIS development server) in both of the browsers, it shows count 1 and increases it when refreshed. But, on closing and reopening of the browser, it starts the counter from 1 again.
I want to use this data, not only in the file which created it, but also in other files hosted on same domain / subdomain.
Can anybody please tell me how can I have a persistent client side data store?