Skip to content

taggar/javascript-storage-intro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

javascript-storage-intro

An introduction to data storage using javascript with cookies and local storage.

Introduction

Sometimes you want to remember something between page loads. Sometimes we save that data on the server, but for some applications we want to store it in the client.

For those use cases we have cookies or localStorage.

About this challenge

Repository javascript-storage-intro
Type of challenge Learning
Duration 1 day

Learning objectives

What and why

  • What is storage?
  • What can be stored
  • Why and when should we store things

Differences

  • The difference between client side storage and server side storage
  • The difference between cookies and localStorage

How

  • How to store something in a cookie
  • How to read something from a cookie
  • How to delete a cookie
  • How to store something in localStorage
  • How to read something from localStorage
  • How to delete something from localStorage

Instructions

Setup

  • Look up what the difference is between localStorage and cookies
  • Create an HTML page
  • Create a repository
  • Commit now, and often 😉

Cookie

  • Add an input element
  • Whenever the user changes the text in the input field, save it in a cookie
  • When the page gets loaded, put the content of the cookie in the input field

LocalStorage

  • Add another input field and do the same with localStorage

Some differences

  • Try out what the maximum amount of text is for each method
  • In the developer tools, look at the request headers, what do you notice?

GDPR

  • Add a delete button for the cookie
  • Add a delete buttn for the localStorage

Multiple inputs

  • For both the cookie and the localStorage

    • add multiple input fields
    • they should all individually work, so if I put something in the first input field for the cookie and something else in the second input field for the cookie, it should, when the user refreshes the page, fill in the field with what the user typed
  • Structure and style it nicely so it is clear which boxes are for cookies and which are for localStorage

Result

https://taggar.github.io/javascript-storage-intro/

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published