2

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.

techraf
  • 4,163
  • 8
  • 27
  • 44
  • http://stackoverflow.com/questions/1062963/how-do-browser-cookie-domains-work#1063760 has a good explanation how cookies work. – Tero Kilkanen Nov 07 '16 at 20:05

1 Answers1

0

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.

Ondra Sniper Flidr
  • 2,623
  • 11
  • 18
  • Yes i knew that, that's clear. But obviously the client don't know if the additive servers are supposed to use cookies, so how does this work? Do the client sends the id anyway? I'm referring to the intestation row of the HTTP request (Cookie: *ID*). That's my question – presgiovanni Nov 07 '16 at 21:25
  • Header row of the HTTP request* – presgiovanni Nov 07 '16 at 21:33
  • Client will send every cookies it has for that domain or hostname (see rules for cookies validity). It depends only on server if it will use values from cookies or not, client is not supposed to do some checks or so. – Ondra Sniper Flidr Nov 07 '16 at 22:18