What Cookies Are

Cookie are little bits of text that your browser writes to your hard disk. Cookies are just chunks of text that are read but not executed, so there's no real danger of someone disguising a virus or a worm as a cookie.

Here's what the lifetime of a cookie looks like:

  • A CGI script or a client-side script tries to set a cookie.

  • If the browser is configured to accept cookies, then the browser takes the cookie and holds it in memory. The cookie is not written to the hard drive yet.

  • The user quits the browser application. At this time, some cookies are written to the hard drive and some are forgotten. The cookies that are remembered are the ones that have expiration dates. Cookies without expiration dates, or those whose dates have passed, ...

Get Advanced JavaScript™: Insights and Innovative Techniques 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.