What is Html Web storage

0 votes
Explain the html web storage in details?. Does it related to any cache related stuffs??
Jan 31, 2020 in HTML by kartik
• 37,520 points
1,616 views

1 answer to this question.

0 votes

With web storage, web applications can store data locally within the user's browser.

Before HTML5, application data had to be stored in cookies, included in every server request. Web 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 and information is never transferred to the server.

Web storage is per origin (per domain and protocol). All pages, from one origin, can store and access the same data. We can store data in an object

HTML Web Storage Objects

HTML web storage provides two objects for storing data on the client:

  • window.localStorage - stores data with no expiration date
  • window.sessionStorage - stores data for one session (data is lost when the browser tab is closed)

Before using web storage, check browser support for localStorage and sessionStorage:

if (typeof(Storage) !== "undefined") {
  // Code for localStorage/sessionStorage.
} else {
  // Sorry! Edureka web site error..........
}
You,can also store data in localstorage as well.

The localStorage Object

The localStorage object stores the data with no expiration date. The data will not be deleted when the browser is closed, and will be available the next day, week, or year.

Example

// Store
localStorage.setItem("lastname", "Edureka");

// Retrieve
document.getElementById("result").innerHTML = localStorage.getItem("lastname");
answered Jan 31, 2020 by Niroj
• 82,840 points

Related Questions In HTML

0 votes
0 answers

What is class in HTML?

what is a class in HTML, I ...READ MORE

Jun 3, 2022 in HTML by Tejashwini
• 3,820 points
387 views
0 votes
0 answers

What is XHTML and is it a subset of HTML

What does XHTML implies and is it ...READ MORE

Jul 4, 2022 in HTML by Tejashwini
• 3,820 points
381 views
0 votes
0 answers

What is the color code for transparent in HTML, is there any code as such?

I need to show a nav bar ...READ MORE

Jul 4, 2022 in HTML by Tejashwini
• 3,820 points
394 views
0 votes
0 answers

What is a form control in HTML?

I was using Twitter Bootstrap which has ...READ MORE

Jul 4, 2022 in HTML by Tejashwini
• 3,820 points
460 views
0 votes
1 answer
0 votes
0 answers

Anyone can help me out to understand the semantic of (document.getElementBYId("demo").innerHTML="Hello") ?

Hello guys, Can Someone helps me to find ...READ MORE

Jan 17, 2020 in Web Development by anonymous
• 37,520 points
950 views
+1 vote
1 answer

What is the relationship between angularjs Scope with controller/view?

Let us consider the below block: <div ng-controller="emp"> ...READ MORE

answered Jan 20, 2020 in Web Development by Niroj
• 82,840 points

edited Jan 21, 2020 by Niroj 1,186 views
+1 vote
1 answer

What are pseudo class in css??

Hey, The state of an element is controlled  by ...READ MORE

answered Jan 20, 2020 in Web Development by Niroj
• 82,840 points

edited Jan 21, 2020 by Niroj 921 views
+1 vote
1 answer

How can i create simple register form using html and css?

Html5 contains lots of elements using which ...READ MORE

answered Jan 31, 2020 in HTML by Niroj
• 82,840 points
4,872 views
0 votes
3 answers

HTML - Change\Update page contents without refreshing\reloading the page?

pushState() # The pushState() method let's you update the URL and create ...READ MORE

answered Dec 15, 2020 in HTML by Gitika
• 65,770 points
61,440 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP