http --- cookie and session tracking

Amazon.com, for example at shopping sites

// (a)客户端:首次请求Amazon.com根页面
GET / HTTP/1.0
Host: www.amazon.com

// (b)服务器:将客户端重定向到一个电子商务软件的URL上
HTTP/1.1 302 Found
Location: http://www.amazon.com:80/exec/obidos/subst/home/redirect.html

// (c)客户端:对重定向的URL发送一个请求
GET /exec/obidos/subst/home/redirect.html HTTP/1.0
Host: www.amazon.com

// (d)服务器:在响应上贴上两个会话cookie,并将用户重定向到另一个URL,这样客户端就会用这些附加的cookie再次发出请求
HTTP/1.1 302 Found
Date: Sun, 02 Dec 2001 03:20:47 GMT
Set-cookie: session-id=002-1145265-8016838; path=/; domain=.amazon.com;
    expires=Sunday, 09-Dec-2001 08:00:00 GMT
Set-cookie: session-id-time=1007884800; path=/; domain=.amazon.com;
    expires=Sunday, 09-Dec-2001 08:00:00 GMT

// (e)客户端发送新的URL(胖URL,将某些状态嵌入到URL中去了), 同时传送2个附加的cookie
GET /exec/obidos/subst/home/redirect.html/ 002-1145265-8016838 HTTP/1.0
Host: www.amazon.com
Cookie: session-id=002-1145265-8016838; session-id-time=1007884800

// (f)服务器重新定向到home.html页面,并附加另外两个cookie
HTTP/1.1 302 Found
Date: Sun, 02 Dec 2001 03:45:40 GMT
Set-Cookie: ubid-main=430-8248051-6231206; path=/; domain.amazon.com;
    expires=Tuesday, 01-Jan-2036 08:00:01 GMT
Location: http://www.amazon.com/exec/obidos/subst/home/home.html/002-1145265-8016838
Set-cookie: x-main="h0...Bf; path=/; domain=.amazon.com;
    expires=Tuesday, 01-Jan-2036 08:00:01 GMT

// (g)客户端获取home.html页面并将所有四个cookie都发送出去
GET /exec/obidos/subst/home/home.html/002-1145265-8016838 HTTP/1.0
Host: www.amazon.com
Cookie: session-id=002-1145265-8016838; session-id-time=1007884800; ubid-main=430-8248051-6231206; x-main="h0...Bf"

// (h)服务器返回页面内容

Reference "HTTP Definitive Guide" P288 ~ P289

Guess you like

Origin blog.csdn.net/piano9425/article/details/92835875