Web Storage

In general, web storage is a web app development method and protocol used for storing data in a web browser. The web storage supports persistent data storage and it is similar to cookies, but with a greatly enhanced capacity and no information stored in the HTTP request header. There are two main web storage types: local storage and session storage, behaving similarly to persistent cookies and session cookies respectively.

Because webOS TV supports the web storage function, it also offers two different storage areas; local storage and session storage. And those storage methods differ in scope and lifetime.

Local Storage

Any web apps can store their data locally with local storage in webOS TV. In fact, you can also store your data in your local web browser and webOS TV emulator too. In previous storing method, app data had to be stored in cookies, included in every server request. But with current HTML standards, the local storage is more secure, and large amounts of data can be stored locally, without affecting website performance.

Unlike cookies, the storage limit is far larger (at least 5 MB) and information is never transferred to the server. If you are planning or developing a game for webOS TV, you can use this local storage to save the user’s final score or owned items. Note that the data in local storage can be deleted by "Initial setting" menu (factory reset). Using a remote server is recommended to keep your data.

When your TV app is updated or removed on webOS TV, the data in the local storage is also deleted.

To simply the process of local storage, we just added the clickcount method to present and check the local storage as below code and after taking the clickcount value, it shows the counted number of local storage.

// Check Local Storage
if (localStorage.clickcount) {
	localStorage.clickcount = Number(localStorage.clickcount) + 1;
} else {
	localStorage.clickcount = 1;

// Retrieve Local Storage
document.getElementById("resultLocal").innerHTML = "LOCAL Storage: " + localStorage.clickcount + " time(s).";

Session Storage

Although the local storage saves its value persistently, the session storage keeps its value on the browser only for the duration of the session. In the view of app lifetime, it maintains a storage area that is available for the duration of the page session. For the webOS TV, you can see your stored values are cleared if you just turn off your app after using the session storage in your app. For example, you are also able to use the session storage for the game score or item which has to be reset whenever the user starts a new game.

Also to check and retrieve the session storage, we added the clickcount method too in the below code. The following example counts the number of times a user has clicked a button, in the current session:

// Check Session Storage
if (sessionStorage.clickcount) {
	sessionStorage.clickcount = Number(sessionStorage.clickcount) + 1;
} else {
	sessionStorage.clickcount = 1;

// Retrieve Session Storage
document.getElementById("resultSession").innerHTML = "SESSION Storage: " + sessionStorage.clickcount + " time(s).";


For your understanding about the web storage in detail, you can download the sample code and its IPK file at the below link for free.


Result in the webOS TV Emulator 

You can launch and see the sample app result in the webOS TV Emulator as below image.


Do’s and Don’ts

  • Do test this sample app on your webOS TV emulator or real webOS TV.
  • Do turn off your app in the webOS TV emulator or webOS TV and check how the value are changed.
  • Don’t forget to shout “Hurray!” when you see the expected results about local storage and session storage.