All about Cookies
The
Web. "State" in this case refers to an application's
ability to work interactively with a user, remembering all data
since the application started, and differentiating between users and
their individual data sets.
An analogy I like to use is a laundry cleaner's shop. You drop
something off, and get a ticket. When you return with the ticket,
you get your clothes back. If you don't have the ticket, then the
laundry man doesn't know which clothes are yours. In fact, he won't
be able to tell whether you are there to pick up clothes, or a brand
new customer. As such, the ticket is critical to maintaining state
between you and the laundry man.
Unfortunately, HTTP is a "stateless" protocol. This means
that each visit to a site (or even clicks within a site) is seen by
the server as the first visit by the user. In essence, the server
"forgets" everything after each request, unless it can
somehow mark a visitor (that is, hand him a "laundry
ticket") to help it remember. Cookies can accomplish this.
1.1 What is
a Cookie?
A cookie is a text-only string that gets entered into the memory of
your browser. This value of a variable that a website sets. If the
lifetime of this value is set to be longer than the time you spend
at that site, then this string is saved to file for future
reference.
1.2 Where
did the term cookies come from?
According to an article written by Paul Bonner for Builder.Com
on 11/18/1997:
"Lou Montulli, currently the protocols manager in
Netscape's client product division, wrote the cookies specification
for Navigator 1.0, the first browser to use the technology. Montulli
says there's nothing particularly amusing about the origin of the
name: 'A cookie is a well-known computer science term that is used
when describing an opaque piece of data held by an intermediary. The
term fits the usage precisely; it's just not a well-known term
outside of computer science circles.'"
http://www.cookiecentral.com/faq/#1.2
contains the following subjects:
|
|
Every machine on the
Internet has a unique identifying number, called an IP Address. A
typical IP address looks like this:
To
make it easier for us humans to remember, IP addresses are normally
expressed in decimal format as a "dotted decimal number"
like the one above. But computers communicate in binary
form. Look at the same IP address in binary:
- 11011000.00011011.00111101.10001001
The
four numbers in an IP address are called octets, because they
each have eight positions when viewed in binary form. If you add all
the positions together, you get 32, which is why IP addresses are
considered 32-bit numbers. Since each of the eight positions can
have two different states (1 or 0) the total number of possible
combinations per octet is 28 or 256. So each octet can contain any value
between 0 and 255. Combine the four octets and you get 232
or a possible 4,294,967,296 unique values!
Out
of the almost 4.3 billion possible combinations, certain values are
restricted from use as typical IP addresses. For example, the IP
address 0.0.0.0 is reserved for the default network and the address
255.255.255.255 is used for broadcasts.
The
octets serve a purpose other than simply separating the numbers.
They are used to create classes of IP addresses that can be
assigned to a particular business, government or other entity based
on size and need. The octets are split into two sections: Net
and Host. The Net section always contains the first octet. It
is used to identify the network that a computer belongs to. Host
(sometimes referred to as Node) identifies the actual
computer on the network. The Host section always contains the last
octet. There are five IP classes plus certain special addresses:
- Default
Network
- The IP address of 0.0.0.0 is used for the default
network.
- Class
A -
This class is for very large networks, such as a major
international company might have. IP addresses with a first
octet from 1 to 126 are part of this class. The other three
octets are used to identify each host. This means that there are
126 Class A networks each with 16,777,214 (224 -2) possible hosts for a total of 2,147,483,648 (231)
unique IP addresses. Class A networks account for half of the
total available IP addresses. In Class A networks, the high
order bit value (the very first binary number) in the first
octet is always 0.
|
Net
|
Host
or Node
|
|
115.
|
24.53.107
|
- Loopback
- The IP address 127.0.0.1 is used as the loopback
address. This means that it is used by the host computer to send
a message back to itself. It is commonly used for
troubleshooting and network testing.
- Class
B -
Class B is used for medium-sized networks. A good example is a
large college campus. IP addresses with a first octet from 128
to 191 are part of this class. Class B addresses also include
the second octet as part of the Net identifier. The other two
octets are used to identify each host. This means that there are
16,384 (214)
Class B networks each with 65,534 (216
-2) possible hosts for a total of 1,073,741,824 (230)
unique IP addresses. Class B networks make up a quarter of the
total available IP addresses. Class B networks have a first bit
value of 1 and a second bit value of 0 in the first octet.
|
Net
|
Host
or Node
|
|
145.24.
|
53.107
|
- Class
C -
Class C addresses are commonly used for small to mid-size
businesses. IP addresses with a first octet from 192 to 223 are
part of this class. Class C addresses also include the second
and third octets as part of the Net identifier. The last octet
is used to identify each host. This means that there are
2,097,152 (221)
Class C networks each with 254 (28
-2) possible hosts for a total of 536,870,912 (229)
unique IP addresses. Class C networks make up an eighth of the
total available IP addresses. Class C networks have a first bit
value of 1, second bit value of 1 and a third bit value of 0 in
the first octet.
|
Net
|
Host
or Node
|
|
195.24.53.
|
107
|
- Class
D -
Used for multicasts,
Class D is slightly different from the first three classes. It
has a first bit value of 1, second bit value of 1, third bit
value of 1 and fourth bit value of 0. The other 28 bits are used
to identify the group of computers the multicast message is
intended for. Class D accounts for 1/16th
(268,435,456 or 228)
of the available IP addresses.
|
Net
|
Host
or Node
|
|
224.
|
24.53.107
|
- Class
E -
Class E is used for experimental purposes only. Like Class D, it
is different from the first three classes. It has a first bit
value of 1, second bit value of 1, third bit value of 1 and
fourth bit value of 1. The other 28 bits are used to identify
the group of computers the multicast message is intended for.
Class E accounts for 1/16th
(268,435,456 or 228) of
the available IP addresses.
|
Net
|
Host
or Node
|
|
240.
|
24.53.107
|
Broadcast -
Messages that are intended for all computers on a network are sent
as broadcasts.
These messages always use the IP address 255.255.255.255 |