Java Reference
In-Depth Information
13
Data Storage 
What You Will learn in this Chapter:
Storing data on the user's computer is possible with cookies and
web storage
Creating cookies is relatively straightforward, but reading them is
complex
Using web storage is easy
Wrox.Com Code doWnloads for this Chapter
You can find the wrox.com code downloads for this chapter at http://www.wiley.com/go/
BeginningJavaScript5E on the Download Code tab. You can also view all of the examples
and related files at http://beginningjs.com .
Our goal as website programmers should be to make the website experience as easy and
pleasant for the user as possible. Clearly, well‐designed pages with easily navigable layouts are
central to this, but they're not the whole story. You can go one step further by learning about
your users and using information gained about them to personalize the website.
For example, imagine a user, whose name you asked on the first visit, returns to your website.
You could welcome her back to the website by greeting her by name. Another good example
is given by a website, such as Amazon's, that incorporates the one‐click purchasing system. By
already knowing the user's purchasing details, such as credit‐card number and delivery address,
you can allow the user to go from viewing a book to buying it in just one click, making the
likelihood of the user purchasing it that much greater. Also, based on information, such as the
previous purchases and browsing patterns of the user, it's possible to make book suggestions.
Such personalization requires that information about users be stored somewhere in between
their visits to the website. Accessing the user's local filesystem from a web application is pretty
much off limits because of security restrictions included in browsers. However, you, as a
 
Search WWH ::




Custom Search