sushil bharwani
sushil bharwani

Reputation: 30187

How does a browser transfers a cookie to server?

I want to understand that how a web browser transfers cookie to the server. Say i am requesting. Google.com will it just transfers the cookie which were created by google.com domain or will it transfer all the cookies. If it transfers just the google ones how does it reads the domain information.

Upvotes: 4

Views: 2190

Answers (3)

Rolando Cruz
Rolando Cruz

Reputation: 2784

I suggest you install Live HTTP Headers to see how browsers "communicate" with servers. Basically, cookies are stored in a way that whenever you visit a site, you browser will look for cookies whose domains matches the domain of the site you are visiting.

If you are using Firefox, you may also install the Web Developer Add-on for you to manage cookies easily. You will see that cookies have these fields:

Name    [name]
Value   [value]
Host    [domains where the cookie will be valid]
Path    [paths within the domain where the cookie will be valid]
...

Your browser will then append a Cookie: field in the HTTP Header whose value correspond to cookie names and their values whenever you visit a site with a matching Host and Path.

Cookie: [name]=[value]

Whenever a website wants to "store" a cookie in your computer, it send a Set-Cookie: header which your browsers will interpret and create or update the corresponding cookie

Set-Cookie: [name]=[value]

Upvotes: 3

Prabath Siriwardena
Prabath Siriwardena

Reputation: 5921

Please check this out... http://www.html5rocks.com/en/tutorials/internals/howbrowserswork/

To answer your question - web sites can read cookies only published under it's domain..

Upvotes: 1

Yann Ramin
Yann Ramin

Reputation: 33167

It will only transfer the cookies related to Google. When Cookies are received, they are specified to operate on a domain or set of domains (such as *.google.com).

Upvotes: 0

Related Questions