开发者

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.


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]


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..


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜