HTTP and cookies working with multiple severs

cookiehttp

Assuming that a simplified diagram of an HTTP/1.1 connection in which the client makes a page and an image request with a cookie assignment can be reduced to this:

(Time trasmission of the second request is not that insignificant, it varies depending on the cookie dimension)

Can someone explain me how cookie technology works when, for example, the picture is saved in a different server than the one in which is saved the page? Do the client send the same cookie id, assigned before, to the second server? Or it depends on how servers are implemented?

Let me say, to avoid misunderstandings, that it's clear to me that if the picture is saved in another server the client has to make another TCP connection.

We are obviously working with persistent HTTP sessions and we are not considering any router between C and S.

Best Answer

It looks you are mixing two things together.

Cookies are stored on the client side. All cookies (depending on URL) are sent with client request, so server has all data in cookies (they are saved on client, no server). There is no Cookie ID.

Maybe you're thinking about session id. In this, only session id is stored in cookie on client side (cookie named PHPSESSID or something like that with value of session id) and all session data are stored on server. In this, there is problem when you want to access session from different server. You can solve it by saving sessions on some shared storage, in database or memcache/redis.