Skip to Content
Head First HTML5 Programming
book

Head First HTML5 Programming

by Eric Freeman, Elisabeth Robson
October 2011
Intermediate to advanced
608 pages
16h 7m
English
O'Reilly Media, Inc.
Content preview from Head First HTML5 Programming

Chapter 9. Storing Things Locally: Web Storage

image with no caption

Tired of stuffing your client data into that tiny closet cookie? That was fun in the ‘90s, but we’ve got much bigger needs today with web apps. What if we said we could get you five megabytes on every user’s browser? You’d probably look at us like we were trying to sell you a bridge in Brooklyn. Well, there’s no need to be skeptical—the HTML5 Web Storage API does just that! In this chapter we’re going to take you through everything you need to store any object locally on your user’s device and to make use of it in your web experience.

How browser storage works (1995 - 2010)

Building a shopping cart? Need to store some user preferences for your site? Or just need to stash some data that you need to be associated with each user? That’s where browser storage comes in. Browser storage gives us a way to persistently store data that we can use in building a web experience.

Behind the Scenes

image with no caption

Up until now there’s been one game in town—the browser cookie—for storing information on the browser. Let’s see how cookies work:

  1. When your browser retrieves a web page, say from “pets-R-us.com,” the server can send a cookie along with its response. Cookies contain one or more key and value pairs:

  2. The next time the browser makes a request to “pets-R-us.com,” it ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Web Programming with HTML5, CSS, and JavaScript

Web Programming with HTML5, CSS, and JavaScript

John Dean
Head First JavaScript Programming

Head First JavaScript Programming

Eric T. Freeman, Elisabeth Robson
Head First HTML with CSS & XHTML

Head First HTML with CSS & XHTML

Elisabeth Robson, Eric Freeman

Publisher Resources

ISBN: 9781449314712Errata Page