• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Reading Cookies

Now that we’ve set a cookie, we can read its data back in. That involves using the document.cookie property—the browser will fill that property with the cookie text for the page that was set earlier automatically.

In the preceding section, we used the setCookie function to set a cookie named cookie1. When we check that property again (even after reloading the same page), we’ll see that document.cookie holds "cookie1=Here is the cookie data!". Note that this text does not contain the expires=date; pair that we set in the cookie in setCookie, because that pair was intended for the browser itself.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint