| |||
![]()
![]()
If you just want to know how to enable or disable cookies, and want to be spared all the gory details, see this FAQ. Besides, your 8 year-old can explain it to you whenever you want. You've been warned... What are Cookies? A cookie is sent as an HTTP header from the web server and the transmitted information is stored locally in a text file. A cookie can be as large as 4 kilobytes or 4000 characters in length. Cookies are not shared by browsers. Depending on the browser you're using, cookies you download will be stored in different ways and in different places on the hard disk. Netscape stores all cookies in one text file called cookies.txt on the PC or magiccookie on the Mac. If you open cookies.txt you'll see that each cookie has its own line and they are grouped by domain. Internet Explorer stores cookies from each domain in seperate text files stored with the cache. All the cookies in one file are stored in one string separated by delimiters. Below is an example of the HTTP header responsible for sending a cookie. Set-Cookie: name=value; expires=date; path=pathname; domain=domainname; secure Each cookie has six definable attributes: a name, a value, an expiration date, the domain for which the cookie can be read, the path in which the cookie can be read, and a Boolean security setting. Name: The name of the cookie. Value: The value associated with the cookie. Expires: The date that, when reached, invalidates the cookie. The date must be given in the following format: Wdy, DD-Mon-YYYY HH:MM:SS GMT. If an expiration date is not specifically defined, the cookies will expire at the end of the session (when the browser is closed) by default. If the cookie's expiration date is set to the current date/time or any date/time already passed, the cookie will be immediately expired and deleted. Path: The path attribute defines a subset of directories in a domain for which the cookie is valid. The path will default to the root directory ("/") unless otherwise defined. Domain: The domain for which the cookie is valid. A domain string of ".aol.com" would define "www.aol.com," "webmaster.info.aol.com," and in fact all sub-domains of aol.com as valid domains for the cookie. Be aware that a domain setting must have at least two periods. A cookie can only be read and modified by an object in the valid domain and path defined in the cookie when it was created. The domain path can not be set to send cookies to a domain outside of the domain where the server creating the cookie resides. The domain attribute is set to the domain of the document sending the cookie by default. Secure: The secure attribute is Boolean. If the attribute is defined, there must be a secure https connection present in order for the cookie to be sent. If the attribute is not defined, the cookie will not require a secure connection to be sent. An Example Chocolate Chip or Pecan? Cookie Recipe Basics For more information on how to turn internet cookies on or off from within the browser, check out our enabling cookies FAQ. In JavaScript, sending a cookie is as easy as declaring the document.cookie DOM object with the desired cookie string. For example consider the following JavaScript cookie definition: document.cookie = "TOAbool = true; expires = Thu,31-Dec-2020 00:00:00 GMT;" This line of code placed within a JavaScript block will define the cookie used in the user agreement example above. It's important to note that despite its appearance, this statement does not redefine the object document.cookie as the cookie string shown. Instead it appends the cookie as a sub-string to the end of a string of all cookies already received from a domain. | |||