store.js - Easily implement local storage (LocalStorage)
store.js is a LocalStorage wrapper that is compatible with all browsers and does not require cookies or Flash. store.js will automatically choose to use localStorage, globalStorage or userData according to the browser to implement the local storage function.
store.js provides a very simple API to implement cross-browser local storage functionality:
store.set('username', 'marcus')
store.get('username')
store.remove('username')
store.clear()
store.set('user', { name: 'marcus', likes: 'javascript' })
var user = store.get('user ')
alert(user.name ' likes ' user.likes)
// Get all stored values
store.getAll().user.name == 'marcus'
// Loop over all stored values
store.forEach(function(key, val) {
console.log(key, '==', val)
})
Get the code: https://github.com/marcuswestin/store.js