<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/web-storage-explained-how-to-use-localstorage-and-sessionstorage-in-javascript-projects-z0adhftrm" -->

---
title: Web Storage Explained – How to Use localStorage and...
description: This article explains how to use web storage in JavaScript to store data locally and securely within a user's browser. It covers the differences between...
canonical: https://daily.dev/posts/web-storage-explained-how-to-use-localstorage-and-sessionstorage-in-javascript-projects-z0adhftrm
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Web Storage Explained – How to Use localStorage and sessionStorage in JavaScript Projects | daily.dev
og:description: This article explains how to use web storage in JavaScript to store data locally and securely within a user's browser. It covers the differences between...
og:url: https://daily.dev/posts/web-storage-explained-how-to-use-localstorage-and-sessionstorage-in-javascript-projects-z0adhftrm
og:image: https://api.daily.dev/og/posts/z0adhFtrM.png
og:image:alt: Web Storage Explained – How to Use localStorage and sessionStorage in JavaScript Projects
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Web Storage Explained – How to Use localStorage and sessionStorage in JavaScript Projects

**[freeCodeCamp](https://daily.dev/sources/freecodecamp)** · [@oluwatobiss](https://daily.dev/oluwatobiss) · 16 min read · 70 upvotes · 6 comments

## Summary

This article explains how to use web storage in JavaScript to store data locally and securely within a user's browser. It covers the differences between session storage and local storage, and provides examples for preventing To-Do items from disappearing, auto-displaying previously added tasks, checking the total items in storage, and emptying session storage.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.freecodecamp.org/news/web-storage-localstorage-vs-sessionstorage-in-javascript/>

## Community discussion

Top comments from developers on daily.dev.

**@albertoferreira** · 1 upvotes

> Amazing work @oluwatobiss

**@arnoldbhebhe** · 0 upvotes

> Love this, thanks for sharing!

**@bouab\_ahmed\_** · 0 upvotes

> greate article @oluwatobiss

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#javascript](https://daily.dev/tags/javascript)

[View this post on daily.dev](https://daily.dev/posts/web-storage-explained-how-to-use-localstorage-and-sessionstorage-in-javascript-projects-z0adhftrm)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Web Storage Explained – How to Use localStorage and sessionStorage in JavaScript Projects","url":"https://daily.dev/posts/web-storage-explained-how-to-use-localstorage-and-sessionstorage-in-javascript-projects-z0adhftrm","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/web-storage-explained-how-to-use-localstorage-and-sessionstorage-in-javascript-projects-z0adhftrm"},"datePublished":"2023-10-09T19:42:59.526Z","dateModified":"2023-10-10T16:00:09.571Z","description":"This article explains how to use web storage in JavaScript to store data locally and securely within a user's browser. It covers the differences between...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/3ed2e52619c32dbed4fac4601fe900f7?_a=AQAEufR","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/3ed2e52619c32dbed4fac4601fe900f7?_a=AQAEufR","isAccessibleForFree":true,"articleSection":"freeCodeCamp","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Person","name":"Oluwatobi Sofela","url":"https://daily.dev/oluwatobiss","image":"https://media.daily.dev/image/upload/s--lB7OC0d6--/f_auto/v1748896667/avatars/avatar_R54UCNW3Noj7k0RM6hCV3?_a=BAMClqUq0","description":"O-sweet-programming, my interest is to make you sweeter for all.","worksFor":{"@type":"Organization","name":"CodeSweetly","logo":"https://media.daily.dev/image/upload/s--rIk_XbbB--/f_auto/v1769004365/companies/codesweetly"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":320}},"commentCount":6,"discussionUrl":"https://daily.dev/posts/web-storage-explained-how-to-use-localstorage-and-sessionstorage-in-javascript-projects-z0adhftrm","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":70},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":6}],"keywords":"webdev,javascript","timeRequired":"PT16M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"freeCodeCamp","item":"https://daily.dev/sources/freecodecamp"},{"@type":"ListItem","position":3,"name":"Web Storage Explained – How to Use localStorage and sessionStorage in JavaScript Projects"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/web-storage-explained-how-to-use-localstorage-and-sessionstorage-in-javascript-projects-z0adhftrm","comment":[{"@type":"Comment","text":"Amazing work @oluwatobiss","datePublished":"2023-12-06T11:48:14.364Z","url":"https://daily.dev/posts/z0adhFtrM#c-onLoFoTP5","author":{"@type":"Person","name":"Alberto Ferreira","url":"https://daily.dev/albertoferreira","image":"https://avatars.githubusercontent.com/u/60177437?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}},{"@type":"Comment","text":"Love this, thanks for sharing!","datePublished":"2024-02-12T23:06:27.426Z","url":"https://daily.dev/posts/z0adhFtrM#c-i6WaqyREy","author":{"@type":"Person","name":"Arnold Bhebhe","url":"https://daily.dev/arnoldbhebhe","image":"https://avatars.githubusercontent.com/u/69598008?v=4"}},{"@type":"Comment","text":"greate article @oluwatobiss","datePublished":"2024-05-01T00:31:39.016Z","url":"https://daily.dev/posts/z0adhFtrM#c-BqNXAmuHD","author":{"@type":"Person","name":"Ahmed BOUAB","url":"https://daily.dev/bouab_ahmed_","image":"https://avatars.githubusercontent.com/u/75287374?v=4"}}]}
```

