Using Web Storage
This topic describes how you can manage application data in key-value format, using the Web storage.
To manage application data, you can use the Web standard Web Storage API.
The Web storage can only store up to 5 MB of data for your application. If you need to store larger amounts, use the file system.
Use the following methods to manage the Web storage:
To store a key-value pair, use the
localStorage.setItem('sample', 'This is just sample text.');
If the key does not exist, it is created with the specified value. If the key already exists, its value is updated.
To retrieve a key value, use the
var value = localStorage.getItem('sample'); console.log(value);
If the key does not exist, the method returns
To remove a key, use the
If the key does not exist, this method does nothing.