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,490 points
211 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,560 points

Related Questions In HTML

0 votes
1 answer

How to Identify Web Element( Button) when there are multiple buttons without any ID

Hi Gangadhar, Do you need the HTML code to ...READ MORE

answered Feb 10, 2020 in HTML by Roshni
• 10,420 points
392 views
0 votes
1 answer

Uncaught ReferenceError: rbi is not defined at HTMLInputElement.onclick

Hello, Just exclude the line rbi() and try ...READ MORE

answered Nov 2, 2020 in HTML by Niroj
• 82,560 points
1,414 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,490 points
152 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,560 points

edited Jan 21, 2020 by Niroj 203 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,560 points

edited Jan 21, 2020 by Niroj 112 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,560 points
1,846 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,870 points
19,931 views
0 votes
1 answer

What is the best practice for updating an already existing web app deployment using ARM?

The Service Principal solution, through the SDK, ...READ MORE

answered Jul 8, 2018 in Other DevOps Questions by Atul
• 10,240 points
113 views
0 votes
1 answer

What is the best "Web API Authentication" practice?

Talking about the best practice, consider the ...READ MORE

answered Aug 6, 2018 in Azure by null_void
• 3,220 points
191 views