{"id":2353,"date":"2015-02-03T13:15:13","date_gmt":"2015-02-03T11:15:13","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=2353"},"modified":"2018-06-20T15:57:00","modified_gmt":"2018-06-20T12:57:00","slug":"html5-local-storage-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/","title":{"rendered":"HTML5 Local Storage Example"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>HTML5 local storage allows web applications to store values locally in the browser and can survive the browser session, just like cookies. Unlike cookies that need to be sent with every HTTP request, thereby affecting website performance, local storage data as information is never transferred to the server.<\/p>\n<p>[ulp id=&#8217;tgm4cmEWcKUikZNn&#8217;]<\/p>\n<p>Additionally, cookies allow you to store only 4K of data per domain, while the local storage allows you at least 5 MB per domain.Local storage offers a simple key &#8211; value store, like a hash table object and comes in two flavors:<\/p>\n<ul>\n<li><strong>Session Storage:<\/strong> stores data for one browser session and is available till the browser\/browser tab is closed. Popup windows opened from the same window can see session storage, and so can iframes inside the same window. However, multiple windows from the same origin (URL) cannot see each other\u2019s session storage.<\/li>\n<li><strong>Local Storage:<\/strong> stores data with no expiration date. The data is available to all windows with the same origin (domain) even when the browser\/browser tabs are reopened or closed.<\/li>\n<\/ul>\n<p>Local storage is supported in the following browsers:<\/p>\n<ul>\n<li>Internet Explorer 8+<\/li>\n<li>Firefox<\/li>\n<li>Opera<\/li>\n<li>Chrome<\/li>\n<li>Safari<\/li>\n<\/ul>\n<p>In both the cases, please note that the storage data will not be available between different browsers.<\/p>\n<p>We will create a simple shopping list example using local storage as shown below:<\/p>\n<figure id=\"attachment_2380\" aria-describedby=\"caption-attachment-2380\" style=\"width: 867px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/01\/HTMLStorage.jpg\"><img decoding=\"async\" class=\"wp-image-2380 size-full\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/01\/HTMLStorage.jpg\" alt=\"html5 local storage\" width=\"867\" height=\"552\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/01\/HTMLStorage.jpg 867w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/01\/HTMLStorage-300x191.jpg 300w\" sizes=\"(max-width: 867px) 100vw, 867px\" \/><\/a><figcaption id=\"caption-attachment-2380\" class=\"wp-caption-text\">HTML Storage<\/figcaption><\/figure>\n<h2>Local Storage<\/h2>\n<p>We will add the external javascript and stylesheet reference in the HTML header .<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n\r\n&lt;head&gt;\r\n&lt;title&gt;HTML5 localStorage Example&lt;\/title&gt;\r\n&lt;meta charset=&quot;UTF-8&quot;&gt;\r\n&lt;meta name=&quot;description&quot; content=&quot;Free Web tutorials&quot;&gt;\r\n&lt;meta name=&quot;keywords&quot; content=&quot;HTML,CSS&quot;&gt;\r\n&lt;meta name=&quot;author&quot; content=&quot;WebCodeGeeks.com&quot;&gt;\r\n&lt;script src=&quot;Storage.js&quot;&gt;&lt;\/script&gt;\r\n&lt;link rel=&quot;stylesheet&quot; href=&quot;StorageStyle.css&quot;&gt;\r\n&lt;\/head&gt;\r\n<\/pre>\n<p>We will call the java script function <code>doShowAll()<\/code> in <code>onload()<\/code> event to a check for browser compatibility and to dynamically draw the table that displays storage name\/value pair.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;body onload=&quot;doShowAll()&quot;&gt;\r\n<\/pre>\n<p>In the <code>CheckBrowser()<\/code> function, we would like to check if the browser supports HTML5 storage or not. There are few ways to do it. We will use the default API\u00a0 to check for the browser compatibility. Alternately, we could have used open source libraries, like <a href=\"http:\/\/modernizr.com\/\">Modernizr<\/a>, that help us to detect the browser support for HTML5 and CSS features.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nfunction CheckBrowser() {\r\n\u00a0\u00a0 \u00a0if ('localStorage' in window &amp;&amp; window&#x5B;'localStorage'] !== null) {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\/\/ we can use localStorage object to store data\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0return true;\r\n\u00a0\u00a0 \u00a0} else {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0 return false;\r\n\u00a0\u00a0 \u00a0}\r\n}\r\n<\/pre>\n<p>Inside the <code>doShowAll()<\/code> if the <code>CheckBrowser()<\/code> function evaluates to true we will dynamically create the table for Shopping list during the page load . You can iterate the keys (property names) of the key-value pairs stored in the local storage, like this<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\u00a0\u00a0 for (i = 0; i &lt;= localStorage.length - 1; i++) {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0key = localStorage.key(i);\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0list += &quot;&lt;tr&gt;&lt;td&gt;&quot; + key + &quot;&lt;\/td&gt;\\n&lt;td&gt;&quot;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0+ localStorage.getItem(key) + &quot;&lt;\/td&gt;&lt;\/tr&gt;\\n&quot;;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0}\r\n\r\n<\/pre>\n<p>Based on the storage value, draw the table dynamically to display the key\/value pair stored in local Storage.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nfunction doShowAll() {\r\n\u00a0\u00a0 \u00a0if (CheckBrowser()) {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0var key = &quot;&quot;;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0var list = &quot;&lt;tr&gt;&lt;th&gt;Name&lt;\/th&gt;&lt;th&gt;Value&lt;\/th&gt;&lt;\/tr&gt;\\n&quot;;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0var i = 0;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0for (i = 0; i &lt;= localStorage.length - 1; i++) {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0key = localStorage.key(i);\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0list += &quot;&lt;tr&gt;&lt;td&gt;&quot; + key + &quot;&lt;\/td&gt;\\n&lt;td&gt;&quot;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0+ localStorage.getItem(key) + &quot;&lt;\/td&gt;&lt;\/tr&gt;\\n&quot;;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0}\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0if (list == &quot;&lt;tr&gt;&lt;th&gt;Name&lt;\/th&gt;&lt;th&gt;Value&lt;\/th&gt;&lt;\/tr&gt;\\n&quot;) {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0list += &quot;&lt;tr&gt;&lt;td&gt;&lt;i&gt;empty&lt;\/i&gt;&lt;\/td&gt;\\n&lt;td&gt;&lt;i&gt;empty&lt;\/i&gt;&lt;\/td&gt;&lt;\/tr&gt;\\n&quot;;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0}\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0document.getElementById('list').innerHTML = list;\r\n\u00a0\u00a0 \u00a0} else {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0alert('Cannot store user preferences as your browser do not support local storage');\r\n\u00a0\u00a0 \u00a0}\r\n}\r\n<\/pre>\n<p>We create a separate <code>div<\/code> element to capture the user inputs and submission. We attach the corresponding JavaScript function in the <code>onClick<\/code> event for the buttons.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;div id=&quot;PlayArea&quot;&gt;\r\n \u00a0\u00a0\u00a0 \u00a0&lt;table&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;tr&gt;\r\n\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;td&gt;&lt;b&gt;Item:&lt;\/b&gt;&lt;input type=text name=name&gt;&lt;\/td&gt;\r\n\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;td&gt;&lt;b&gt;Quantity:&lt;\/b&gt;&lt;input type=text name=data&gt;&lt;\/td&gt;\r\n\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;\/tr&gt;\r\n\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0 &lt;tr&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;td&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0 &lt;input type=button value=&quot;Save&quot;\u00a0\u00a0 onclick=&quot;SaveItem()&quot;&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0 &lt;input type=button value=&quot;Modify&quot; onclick=&quot;ModifyItem()&quot;&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0 &lt;input type=button value=&quot;Remove&quot; onclick=&quot;RemoveItem()&quot;&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0 &lt;\/td&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0 &lt;\/tr&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;\/table&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<p>Inside our style sheet we have formatted the <code>div<\/code> information as follows.<\/p>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">\r\n#PlayArea {\r\n\u00a0\u00a0 \u00a0border: 1px dotted blue;\r\n\u00a0\u00a0 \u00a0padding: 6px;\r\n\u00a0\u00a0 \u00a0background-color: #ccc;\r\n\u00a0\u00a0 \u00a0margin-right: 50%;\r\n}\r\n<\/pre>\n<p>You can set properties on the\u00a0<code>localStorage<\/code> object just like with a normal JavaScript object. Here is an example on how we can set the local storage property <code>myProperty<\/code> to the value <code>myValue<\/code>.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nlocalStorage.myProperty = &quot;myValue&quot;;\r\n<\/pre>\n<p>You can delete local storage property like this.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\ndelete localStorage.myProperty;\r\n<\/pre>\n<p>Alternately use the following methods to access the <code>localStorage<\/code><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nlocalStorage.setItem ('propertyName', 'value');\r\nlocalStorage.getItem ('propertyName');\r\nlocalStorage.removeItem ('propertyName');\r\n<\/pre>\n<p>For saving the key\/value pair capture the value of the corresponding javascript object and call the <code>.setItem<\/code> method<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nfunction SaveItem() {\r\n\u00a0   var name = document.forms.ShoppingList.name.value;\r\n\u00a0\u00a0 \u00a0var data = document.forms.ShoppingList.data.value;\r\n\u00a0\u00a0 \u00a0localStorage.setItem(name, data);\r\n\u00a0\u00a0 \u00a0doShowAll(); \u00a0\r\n}\r\n<\/pre>\n<p>To fetch an existing key\/value pair we will use the <code>.getItem<\/code> method<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nfunction ModifyItem() {\r\n\u00a0\u00a0 \u00a0var name = document.forms.ShoppingList.name.value;\r\n\u00a0\u00a0 \u00a0document.forms.ShoppingList.data.value = localStorage.getItem(name);\r\n\u00a0\u00a0 \u00a0doShowAll();\r\n}\r\n<\/pre>\n<p>We will use the <code>.removeItem<\/code> method to delete from the storage.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nfunction RemoveItem() {\r\n\u00a0\u00a0 \u00a0var name = document.forms.ShoppingList.name.value;\r\n\u00a0\u00a0 \u00a0document.forms.ShoppingList.data.value = localStorage.removeItem(name);\r\n\u00a0\u00a0 \u00a0doShowAll();\r\n}\r\n<\/pre>\n<p>There is another method for local storage that allows you to clear the entire local storage.We have called the <code>ClearAll()<\/code> function in the <code>onClick <\/code>\u00a0 event of the &#8220;Clear&#8221; button.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;input type=button value=&quot;Clear&quot; onclick=&quot;ClearAll()&quot;&gt;\r\n<\/pre>\n<p>We have used the <code>clear<\/code> method to clear the local storage as shown below.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nfunction ClearAll() {\r\n\u00a0\u00a0 \u00a0localStorage.clear();\r\n\u00a0\u00a0 \u00a0doShowAll();\r\n}\r\n<\/pre>\n<h2>Session Storage<\/h2>\n<p>The <code>sessionStorage<\/code> object works in same way as the <code>localStorage<\/code>. You can substitute the above example with <code>sessionStorage<\/code> object\u00a0 to persist the data only for the session. Once the user closes the browser window, the storage will be cleared. To summarize, the API for <code>localStorage<\/code> and <code>sessionStorage<\/code> is exactly the same, and allows you to use the following methods:<\/p>\n<ul>\n<li>setItem(key, value);<\/li>\n<li>getItem(key)<\/li>\n<li>removeItem(key)<\/li>\n<li>clear()<\/li>\n<li>key(index)<\/li>\n<li>length<\/li>\n<\/ul>\n<h2>Key points<\/h2>\n<ul>\n<li>The browser by default allows 5 MB of storage per domain . <code>QUOTA_EXCEEDED_ERR<\/code> is the exception that will get thrown if you exceed your storage quota of 5 megabytes. You might want to put a try, catch block to catch the specific error.<\/li>\n<li>The <code>localStorage<\/code> and <code>sessionStorage<\/code> object by default only support string name\/value storage. If you want to store arrays or objects into local storage use <code>JSON.stringify<\/code> to store the value and <code>JSON.parse<\/code> to retrieve the value.<\/li>\n<li>In order to keep track programmatically of when the storage area changes, you can trap the <code>storage<\/code> event. The <code>storage<\/code> event is fired on the <code>window<\/code> object whenever you insert, update or delete a session or local storage property. The storage event is only emitted in other browser windows than the one that inserted, updated or deleted the session or local storage objects which means that for local storage, events are visible to all other windows open with the same origin, including pop up windows and iframes while for session storage events are only visible in pop up windows and iframes.<\/li>\n<li>The\u00a0 key name should be unique for each domain.<\/li>\n<\/ul>\n<h2>Download the Source Code<\/h2>\n<p>This was an example of HTML local storage.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here:\u00a0<a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/01\/HTMLStorage.zip\"><strong>HTMLStorage<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction HTML5 local storage allows web applications to store values locally in the browser and can survive the browser session, just like cookies. Unlike cookies that need to be sent with every HTTP request, thereby affecting website performance, local storage data as information is never transferred to the server. [ulp id=&#8217;tgm4cmEWcKUikZNn&#8217;] Additionally, cookies allow you &hellip;<\/p>\n","protected":false},"author":47,"featured_media":914,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[90],"class_list":["post-2353","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-html5","tag-storage"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>HTML5 Local Storage Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Interested to learn more about local storage? Check our Example on how HTML5 local storage allows web applications to store values locally in the browser!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"HTML5 Local Storage Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Interested to learn more about local storage? Check our Example on how HTML5 local storage allows web applications to store values locally in the browser!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2015-02-03T11:15:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-06-20T12:57:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Arindam Chattopadhya\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Arindam Chattopadhya\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/\"},\"author\":{\"name\":\"Arindam Chattopadhya\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/78b9675665f8627e97ed2dd1fd8cdf00\"},\"headline\":\"HTML5 Local Storage Example\",\"datePublished\":\"2015-02-03T11:15:13+00:00\",\"dateModified\":\"2018-06-20T12:57:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/\"},\"wordCount\":1388,\"commentCount\":8,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"keywords\":[\"Storage\"],\"articleSection\":[\"HTML5\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/\",\"name\":\"HTML5 Local Storage Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"datePublished\":\"2015-02-03T11:15:13+00:00\",\"dateModified\":\"2018-06-20T12:57:00+00:00\",\"description\":\"Interested to learn more about local storage? Check our Example on how HTML5 local storage allows web applications to store values locally in the browser!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"HTML5\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/html5\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"HTML5 Local Storage Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/78b9675665f8627e97ed2dd1fd8cdf00\",\"name\":\"Arindam Chattopadhya\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4c54fbd5748a5a51f90f73ca68fe86ae6bf8e416966a283b2c05bf15c86c4dd3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4c54fbd5748a5a51f90f73ca68fe86ae6bf8e416966a283b2c05bf15c86c4dd3?s=96&d=mm&r=g\",\"caption\":\"Arindam Chattopadhya\"},\"description\":\"Arindam has completed Masters in Information Technology. His expertise includes enterprise applications architecture, application integration, legacy connectivity, user interface engineering, systems analysis and distributed systems architecture and design. He has hand-on expertise on Java EE , web technology and mobile application development.\",\"sameAs\":[\"http:\/\/www.webcodegeeks.com\/\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/arindam-chattopadhya\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"HTML5 Local Storage Example - Web Code Geeks - 2026","description":"Interested to learn more about local storage? Check our Example on how HTML5 local storage allows web applications to store values locally in the browser!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/","og_locale":"en_US","og_type":"article","og_title":"HTML5 Local Storage Example - Web Code Geeks - 2026","og_description":"Interested to learn more about local storage? Check our Example on how HTML5 local storage allows web applications to store values locally in the browser!","og_url":"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2015-02-03T11:15:13+00:00","article_modified_time":"2018-06-20T12:57:00+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","type":"image\/jpeg"}],"author":"Arindam Chattopadhya","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Arindam Chattopadhya","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/"},"author":{"name":"Arindam Chattopadhya","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/78b9675665f8627e97ed2dd1fd8cdf00"},"headline":"HTML5 Local Storage Example","datePublished":"2015-02-03T11:15:13+00:00","dateModified":"2018-06-20T12:57:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/"},"wordCount":1388,"commentCount":8,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","keywords":["Storage"],"articleSection":["HTML5"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/","url":"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/","name":"HTML5 Local Storage Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","datePublished":"2015-02-03T11:15:13+00:00","dateModified":"2018-06-20T12:57:00+00:00","description":"Interested to learn more about local storage? Check our Example on how HTML5 local storage allows web applications to store values locally in the browser!","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-local-storage-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"HTML5","item":"https:\/\/www.webcodegeeks.com\/category\/html5\/"},{"@type":"ListItem","position":3,"name":"HTML5 Local Storage Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/78b9675665f8627e97ed2dd1fd8cdf00","name":"Arindam Chattopadhya","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4c54fbd5748a5a51f90f73ca68fe86ae6bf8e416966a283b2c05bf15c86c4dd3?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4c54fbd5748a5a51f90f73ca68fe86ae6bf8e416966a283b2c05bf15c86c4dd3?s=96&d=mm&r=g","caption":"Arindam Chattopadhya"},"description":"Arindam has completed Masters in Information Technology. His expertise includes enterprise applications architecture, application integration, legacy connectivity, user interface engineering, systems analysis and distributed systems architecture and design. He has hand-on expertise on Java EE , web technology and mobile application development.","sameAs":["http:\/\/www.webcodegeeks.com\/"],"url":"https:\/\/www.webcodegeeks.com\/author\/arindam-chattopadhya\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/2353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/47"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=2353"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/2353\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/914"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=2353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=2353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=2353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}