Chapter 12. Creating and Consuming Cookies

After reading this chapter, you'll be able to

  • Understand HTTP cookies.

  • Create cookies with JavaScript and send them to the browser.

  • Understand how to make a cookie expire in the future.

  • Understand how to set the path and domain for a cookie.

  • Read cookies from the browser and parse their contents.

A Look at Cookies

Hypertext Transfer Protocol (HTTP) cookies are bits of data that are sent back and forth between a client (usually a browser) and a server. They are used to keep track of everything from the state of an application (such as where you are in the application), to session information, to information about your visit such as your user ID (though there are plenty of reasons why you shouldn't store user ...

Get JavaScript Step by Step now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.