Posted by
admin on Nov 14th, 2010 in
Development |
Comments Off
Limitations Of Cookies
In part 2 of this article, I hinted at some limitations that are placed on cookies. In general these constraints aren’t much of a problem, and are more than made up for by the strength of cookies: persistence. Anyway, here are the specifics:
- Browsers may limit the total number of cookies they will store to as few as 300 cookies total. When this limit is reached, cookies are discarded beginning with the least recently used.
- The name and value of any given cookie must combine to be less than 4 kilobytes in size. This is plenty for most applications. If the cookie exceeds this size, it is trimmed automatically by the browser to the 4 kilobyte limit.
- Browsers may limit the number of cookies they will store to as few as 20 cookies per server or domain. This means that www.sausagetools.com and www2.sausagetools.com may each set up to 20 cookies before the browser begins discarding old ones
In addition, the cookies we’ve created so far have the following limitations:
- Cookies may only be read by documents in the same domain as the document that created the cookie. For example, a Web page from www2.sausagetools.com may not read a cookie set by a page from www1.sausagetools com. However, a Web page from support.sausagetools.com can read a cookie set by sausagetools.com, since it is located in the sausagetools.com domain.
- Cookies may only be read by documents in the same directory as the document that created the cookie. This includes subdirectories. For example, a cookie created by a document in the /www directory of www.sausagetools.com can be read by a document in the /www/support directory of the same server. However, it cannot be read by a document in the /www2 directory.
- Cookies are automatically destroyed when the user closes the Web browser.
These three limitations, however, can be avoided. For the rest of this article, we’ll be looking at some of the advanced options supported by cookies that let us share our cookies with other domains and directories.