What Cookies Can and Can't Do

Because cookies involve writing to and reading from your visitors' hard drives, cookie-friendly browsers deal with lots of security issues. As a result, using cookies has many limitations. The most important ones for the purposes of this chapter are these:

  • Not everyone has a cookie-friendly browser.

  • Not everyone who has a cookie-friendly browser chooses to accept cookies (but most people do).

  • Each domain may have only 20 cookies (so use them sparingly).

  • There is a 4KB limit on the amount of information one domain can store using cookies. That's just over 4,000 characters—actually quite a lot.

  • A website can set and read only its own cookies (for example, Yahoo! can't read AOL's cookies).

Keep these limitations in mind when ...

Get The Book of JavaScript, 2nd Edition 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.