<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Difference between local storage and session storage &#8211; Sibeesh Passion</title>
	<atom:link href="https://mail.sibeeshpassion.com/tag/difference-between-local-storage-and-session-storage/feed/" rel="self" type="application/rss+xml" />
	<link>https://mail.sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Tue, 28 Nov 2017 16:22:45 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>/wp-content/uploads/2017/04/Sibeesh_Passion_Logo_Small.png</url>
	<title>Difference between local storage and session storage &#8211; Sibeesh Passion</title>
	<link>https://mail.sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Basic Difference Between Local Storage and Session Storage in HTML 5</title>
		<link>https://mail.sibeeshpassion.com/basic-difference-between-local-storage-and-session-storage-in-html-5/</link>
					<comments>https://mail.sibeeshpassion.com/basic-difference-between-local-storage-and-session-storage-in-html-5/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Sun, 29 Mar 2015 20:14:03 +0000</pubDate>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Difference between local storage and session storage]]></category>
		<category><![CDATA[Local Storage]]></category>
		<category><![CDATA[Session Storage]]></category>
		<category><![CDATA[Storage in HTML5]]></category>
		<guid isPermaLink="false">https://sibeeshpassion.com/?p=1501</guid>

					<description><![CDATA[[toc] Introduction This article explains what is the basic difference between HTML 5 local storage and session storage. Basically, both session storage and local storage are part of storage mechanism which is introduced with HTML5. By using these two, we can store information on client side itself. I hope you will like it. If you are new to the term local storage, I recommend you to read my article here: Local Storage Basic scenario where you can use If you need to carry a value throughout your application or throughout your pages, you can use local storage. For example, we [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>[toc]</p>
<h3>Introduction</h3>
<p>
This article explains what is the basic difference between HTML 5 local storage and session storage. Basically, both session storage and local storage are part of storage mechanism which is introduced with HTML5. By using these two, we can store information on client side itself.  I hope you will like it.</p>
<p>If you are new to the term local storage, I recommend you to read my article here: <a href="http://sibeeshpassion.com/working-with-client-side-local-storage/" target="_blank">Local Storage</a></p>
<p><h3>Basic scenario where you can use</h3>
<p>
If you need to carry a value throughout your application or throughout your pages, you can use local storage. For example, we can store a logged-in username in local storage that we may need to access all the pages. I strongly recommend to not store any secured data (for example a “password”) in local storage.</p>
<p>In some scenario, we may need to set a key element depending on the pages we have in the application. For example, if we need to store the page name (any key element that may be different).<br />
So let’s start</p>
<p><h3>Using the code</h3>
<p>
Here in my application, I have added two HTML5 pages.</p>
<p><em>HtmlPage1.html</em><br />
<em>HtmlPage2.html</em></p>
<p>In <em>HtmlPage1.html</em> I have set local storage and session storage, now I am trying to access that in <em>HtmlPage2.html</em>. Please see the following source.</p>
<p><em>HtmlPage1.html</em><br />
[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html<br />
    xmlns=“http://www.w3.org/1999/xhtml”&gt;<br />
    &lt;head&gt;<br />
        &lt;title&gt;Difference between local storage and session storage&lt;/title&gt;<br />
        &lt;script&gt;<br />
            localStorage.setItem(“myKey”, 1);<br />
            sessionStorage.setItem(“myKey”, 1);<br />
            var myVal = localStorage.getItem(“myKey”);<br />
            alert(“My local storage value is : ” + myVal);<br />
            alert(“My session storage value is : ” + sessionStorage.getItem(“myKey”));<br />
        &lt;/script&gt;<br />
    &lt;/head&gt;<br />
    &lt;body&gt;<br />
    &lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p><em>HtmlPage2.html</em><br />
[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html<br />
    xmlns=“http://www.w3.org/1999/xhtml”&gt;<br />
    &lt;head&gt;<br />
        &lt;title&gt;Difference between local storage and session storage&lt;/title&gt;<br />
        &lt;script&gt;<br />
            var myVal = localStorage.getItem(“myKey”);<br />
            alert(“My local storage value is : ” + myVal);<br />
            alert(“My session storage value is : ” + sessionStorage.getItem(“myKey”));<br />
        &lt;/script&gt;<br />
    &lt;/head&gt;<br />
    &lt;body&gt;<br />
    &lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p>When you run the first page, in the browser console you will see as in the following image.</p>
<p><a href="http://sibeeshpassion.com/wp-content/uploads/2015/03/local-storage.jpg"><img fetchpriority="high" decoding="async" src="http://sibeeshpassion.com/wp-content/uploads/2015/03/local-storage.jpg" alt="local storage" width="624" height="135" class="alignnone size-full wp-image-8461" srcset="/wp-content/uploads/2015/03/local-storage.jpg 624w, /wp-content/uploads/2015/03/local-storage-300x65.jpg 300w, /wp-content/uploads/2015/03/local-storage-620x135.jpg 620w, /wp-content/uploads/2015/03/local-storage-400x87.jpg 400w" sizes="(max-width: 624px) 100vw, 624px" /></a></p>
<p>Figure: Local Storage</p>
<p><a href="http://sibeeshpassion.com/wp-content/uploads/2015/03/session-storage.jpg"><img decoding="async" src="http://sibeeshpassion.com/wp-content/uploads/2015/03/session-storage.jpg" alt="session storage" width="624" height="135" class="alignnone size-full wp-image-8462" srcset="/wp-content/uploads/2015/03/session-storage.jpg 624w, /wp-content/uploads/2015/03/session-storage-300x65.jpg 300w, /wp-content/uploads/2015/03/session-storage-620x135.jpg 620w, /wp-content/uploads/2015/03/session-storage-400x87.jpg 400w" sizes="(max-width: 624px) 100vw, 624px" /></a></p>
<p>Figure: Session Storage</p>
<p>Now it is time to run the second page. Once you run that please check in the console. You can see as follows.</p>
<p><a href="http://sibeeshpassion.com/wp-content/uploads/2015/03/htmlpage2-local-storage.jpg"><img decoding="async" src="http://sibeeshpassion.com/wp-content/uploads/2015/03/htmlpage2-local-storage.jpg" alt="htmlpage2 local storage" width="624" height="301" class="alignnone size-full wp-image-8471" srcset="/wp-content/uploads/2015/03/htmlpage2-local-storage.jpg 624w, /wp-content/uploads/2015/03/htmlpage2-local-storage-300x145.jpg 300w, /wp-content/uploads/2015/03/htmlpage2-local-storage-400x193.jpg 400w" sizes="(max-width: 624px) 100vw, 624px" /></a></p>
<p>Figure: Local storage</p>
<p><a href="http://sibeeshpassion.com/wp-content/uploads/2015/03/htmlpage2-session-storage.jpg"><img decoding="async" src="http://sibeeshpassion.com/wp-content/uploads/2015/03/htmlpage2-session-storage.jpg" alt="htmlpage2 session storage" width="624" height="307" class="alignnone size-full wp-image-8481" srcset="/wp-content/uploads/2015/03/htmlpage2-session-storage.jpg 624w, /wp-content/uploads/2015/03/htmlpage2-session-storage-300x148.jpg 300w, /wp-content/uploads/2015/03/htmlpage2-session-storage-400x197.jpg 400w" sizes="(max-width: 624px) 100vw, 624px" /></a></p>
<p>Figure: Session storage</p>
<p>Please note that session storage is null. You can see the session storage only if you set it on that running page.
</p>
<h3>Conclusion</h3>
<p>
Thanks a lot for reading. Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.
</p>
<h3>Your turn. What do you think?</h3>
<p>
A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.
</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/basic-difference-between-local-storage-and-session-storage-in-html-5/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
