Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 559
sushil bharwani Avatar asked Oct 22 '25 03:10

sushil bharwani


1 Answers

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]
like image 180
Rolando Cruz Avatar answered Oct 24 '25 09:10

Rolando Cruz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!