Session Handling Using localStorage

1. Introduction


After completing this module, you are expected to:

    • Use cookies and local storage as a means of establishing sessions.

          In the previous module, we have learned that cookies are used to store user information and are sent to servers with every request. To make sure that cookies do not take up bandwidth and slow down the loading of webpages, they should have small file sizes, thus must contain only a small amount of information. Another downside to cookies is they must be sent along with each request.

          To solve these problems, an alternative was provided and standardized by the World Wide Web Consortium (W3C). Web storage can contain more data than cookies and they do not have to be sent to a server each time. Instead, data is stored client-side, which means that it is stored in the computer of the user. With this feature, more data is available for the website without having to sacrifice loading time. The user’s data is also more secure because it does not have to be sent to servers.