The Document object has a property named cookie that was not discussed in Chapter 15. On the surface, this property appears to be a simple string value; however, the cookie property is much more than this: it enables JavaScript code to persistently store data to the user's hard disk and to retrieve data that was previously stored in this way. Client-side persistence is an easy way to give web applications a memory: a web site can store user preferences so that they can be used again when the user revisits the page, for example. Cookies are also used for server-side scripting and are a standard extension to the HTTP protocol. All modern web browsers support them and allow them to be scripted with the Document.cookie property. There are other client-side persistence mechanisms that are more powerful but less standard than cookies, and I discuss them briefly at the end of this chapter. |