私はLocalStorageを使用しますが、使い方は非常に簡単です。プレーンテキストを保存できます:
// Writing 'something' in localStorage.myvariable
localStorage.myvariable = 'something'
// Displaying the previous variable
console.log(localStorage.myvariable)
プレーンテキストでは不十分で、データ構造を保存する必要がある場合は、次のようなものを実装できます。
Storage.prototype.setObject = function(key, value) { this.setItem(key, JSON.stringify(value)); }
Storage.prototype.getObject = function(key) { var value = this.getItem(key);return value && JSON.parse(value); }
// Storing a JSON object
localStorage.setObject('myObject', {key1: 'value', key2: 'value2'});
// Accessing the object
localStorage.getObject('myObject')