views:

41

answers:

1

After you enter your name and password on a website, a cookie is stored on your computer. Your computer then sends information from that cookie to the website whenever you browse to another page on that site so that the site knows who you are.

How is information from the cookie sent? Does the browser append information from within the cookie to the html address?

+2  A: 

The browser sends a HTTP (http://www.w3.org/Protocols/rfc2616/rfc2616.html) request, which includes the URL, the request method (GET, POST etc), cookies and a whole bunch of other stuff. Here's the request from my browser to this SO page:

GET /questions/2575970/how-are-cookies-sent-to-a-website HTTP/1.1
Host: stackoverflow.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Cookie: __utma=140021253.1463780230058740000.12348924611.1279210754.1270438283.1398; __utmz=140222553.12686423964.1149.21...
If-Modified-Since: Sun, 04 Apr 2010 21:30:58 GMT

Note that the cookie doesn't normally contain the user name, just a index to a lookup table that's stored server-side.

Alohci
Also, rather than an ID used for server-side look-up of user/session data, the cookie sometimes contains the user name or other data values, _in an encrypted fashion_.
mjv
How are you able to see all of this information that the browser sends in its request?
Phenom
@Phenom: check this answer: http://stackoverflow.com/questions/2575886/how-do-cookies-work-when-browsing-websites/2575979#2575979 in another of your recent questions.
mjv