📘
Deuterium Wiki
  • Hello
  • Linux
    • cmd
      • du: 显式文件大小
      • seq: 生成序列
      • cat: 连接
      • cp: 复制
      • cd: 切换目录
      • mv: 移动
    • awk
      • 执行awk脚本
      • 删除空行
      • 个数统计
      • 文件的交集
      • 文件的差集
    • mysql
      • 删除重复数据
      • 导出数据不带标题
  • Reading
    • Novel
      • 《基督山伯爵》人物关系
    • Awesome CS Books
      • csapp-3e-homework-solution
        • 1. A Tour of Computer Systems
        • 2. Representing and Manipulating Information
          • 2.55 Compile and Run
          • 2.56 Another Try
          • 2.57 More show Procedures
          • 2.58 Check Little-Endian
          • 2.59 Bit Expressions
          • 2.60 Replace Byte
          • 2.61 More Bit Expressions
          • 2.62 Check Arithmetic Right Shift
          • 2.63 Logic & Arithmetic Right Shift
          • 2.64 Any Odd One
          • 2.65 Odd Ones
          • 2.66 Leftmost One
          • 2.67 Int Size is 32
          • 2.68 Lower One Mask
          • 2.69 Rotate Left
          • 2.70 Fits Bits
          • 2.71 Xbyte
          • 2.72 Copy Int
          • 2.73 Saturating Add
          • 2.74 Sub OK
          • 2.75 Unsigned High Prod
          • 2.76 calloc
          • 2.77 Multiple By Shifts
          • 2.78 Divide Power 2
          • 2.79 Mul3div4
          • 2.80 Three Fourths
          • 2.81 Generate Bits
          • 2.82 Signed and Unsigned
          • 2.83 Binary Floating Value
          • 2.84 Float Le
          • 2.85 Floating Point I
          • 2.86 Extend Precision
          • 2.87 Floating-Point II
          • 2.88 Floating-Point III
          • 2.89 Floating-Point IV
          • 2.90 fpwr2
          • 2.91 π
          • 2.92 Float Negate
          • 2.93 Float Absval
          • 2.94 Float Twice
          • 2.95 Float Half
          • 2.96 Float f2i
          • 2.97 Float i2f
        • 3. Machine-Level Representation of Programs
          • 3.58 Decode
          • 3.59 128-bit Multiply
          • 3.60 For Loop
          • 3.61 Conditional Data Transfer
          • 3.62 Switch I
          • 3.63 Switch II
          • 3.64 Multiple Dimension Array I
          • 3.65 Multiple Dimension Array II
          • 3.66 Multiple Dimension Array III
          • 3.67 Caller and Callee
          • 3.68 Alignment
          • 3.69 Struct
          • 3.70 Union
          • 3.71 fgets
          • 3.72 Variable-Size Stack
          • 3.73 Find Range I
          • 3.74 Find Range II
          • 3.75 Complex
      • tcpv1
        • ch01: Introduction
        • ch02: Link Layer
        • ch03: Internet Protocol
        • ch04: Address Resolutin Protocol
        • ch05: Reverse Address Resolution Protocol
        • ch06: Internet Control Message Protocol
        • ch07: Ping Program
        • ch08: Traceroute Program
        • ch09: IP Routing
        • ch10: Dynamic Routing Protocols
        • ch11: User Datagram Protocol
        • ch12: Broadcasting and Multicasting
        • ch13: Internet Group Management Protocol
        • ch14: The Domain Name System
        • ch15: Trivial File Transfer Protocol
        • ch16: Boostrap Protocol
        • ch17: Transmission Control Protocol
        • ch18: TCP Connection Establishment and Termination
        • ch 19: TCP Interactive Data Flow
        • ch20: TCP Bulk Data Flow
      • http
        • ch01: Overview of HTTP
        • ch02: URLs and Resources
        • ch03: HTTP Messages
        • ch04: Connection Management
        • ch05: Web Servers
        • ch06: Proxies
        • ch07: Caching
        • ch08: Integration Points
        • ch09: Web Robots
        • ch10: HTTP-NG
        • ch11: Client Identification and Cookies
        • ch12: Basic Authentication
        • ch13: Digest Authentication
        • ch14: Secure HTTP
        • ch15: Entities and Encodings
        • ch16: Internationalizated
        • ch17: Content Negotiation and Transcoding
        • ch18: Web Hosting
        • ch19: Publishing Systems
        • ch20: Redirections and Load Balancing
        • ch21: Logging and Usage Tracking
    • 提升认知
      • 《为什么需要生物学思维》
      • 《大话西方艺术史》
  • Mathematics
Powered by GitBook
On this page
  • 1. The Personal Touch
  • 2. HTTP Headers
  • 3. Client IP Address
  • 4. User Login
  • 5. Fat URLs
  • 6. Cookies
  • 6.1 Types of Cookies
  • 6.2 How Cookies Work
  • 6.3 Cookie Jar: Client-Side State
  • 6.4 Different Cookies for Different Sites
  • 6.5 Cookie Ingredients
  • 6.6 Cookies and Session Tracking
  • 6.8 Cookies, Security, and Privacy

Was this helpful?

  1. Reading
  2. Awesome CS Books
  3. http

ch11: Client Identification and Cookies

Previousch10: HTTP-NGNextch12: Basic Authentication

Last updated 4 years ago

Was this helpful?

11.客户端识别与cookie

1. The Personal Touch

Mechanisms to identify users:

  • HTTP headers that carry information about user identity

  • Client IP address tracking, to identify users by their IP address

  • User login, using authentication to identify users

  • Fat URLs, a technique for embedding identify in URLs

  • Cookies, a powerful but efficient technique for maintaining persistent identity

2. HTTP Headers

HTTP headers carry clues about users:

Header name

Header type

Description

From

Request

User's email address

User-Agent

Request

User's browser software

Referer

Request

Page user came from by following link

Authorization

Request

Username and password

Client-ip

Extension(Request)

Client's IP address

X-Forwarded-For

Extension(Request)

Client's IP address

Cookie

Extension(Request)

Server-generated ID label

3. Client IP Address

Limits:

  • Client IP addresses describe only the computer being used, not the user.

  • Many Internet service providers dynamically assign IP addresses to users when they log in.

  • The Network Address Translation (NAT) devices obscure the IP addresses of the real clients behind the firewall.

  • HTTP proxies and gateways typically open new TCP connections to the origin server.

4. User Login

Flow:

5. Fat URLs

Some web sites keep track of user identity by generating special versions of each URL for each user.

URLs modified to include user state information are called fat URLs.

Problems:

  • Ugly URLs: the fat URLs displayed in the browser are confusing for new users.

  • Can't share URLs: the fat URLs contain state information about a particular user and session.

  • Breaks caching: Generating user-specific versions of each URL means that there are no longer commonly accessed URLs to cache.

  • Extra server load: the server needs to rewrite HTML pages to fatten the URLs.

  • Not persistent across sessions: All information is lost when the user logs out, unless he bookmarks the particular fat URL.

6. Cookies

Cookies are the best current way to identify users and allow persistent sessions.

6.1 Types of Cookies

  • session cookies

  • persistent cookies

6.2 How Cookies Work

6.3 Cookie Jar: Client-Side State

The basic idea of cookies is to let the browser accumulate a set of server-specific information, and provid this information back to the server each time you visit.

The browser is responsible for storing the cookie information, this system is called client-side state.

6.4 Different Cookies for Different Sites

A browser typically sends only two or three cookies to each site.

In general, a browser sends to a server only those cookies that the server generated.

6.4.1 Cookie Domain attribute

A server generating a cookie can control which sites get to see that cookie by adding a Domain attribute to the Set-Cookie response header:

Set-cookie: user="mary17"; domain="airtravelbargains.com"

If the user visits www.airtravelbargins.com, the following Cookie header will be issued:

Cookie: user="mary17"

6.4.2 Cookie Path attribute

A special auto-rental cookie might be generated like this:

Set-cookie: pref=compact; domain="airtravelbargains.com"; path=/autos/
Cookie: user="mary17"
Cookie: user="mary17"
Cookie: pref=compact

6.5 Cookie Ingredients

There are two different versions of cookie specifications in use.

6.5.1 Version 0 (Netscape) Cookies

Format:

Set-Cookie: name=value [; expires=date] [; path=path] [; domain=domain] [; secure]
Cookie: name1=value1 [; name2=value2] ...

Attributes:

Set-Cookie attribute

Examples

NAME=VALUE

Set-Cookie: customer=Mary

Expires

Set-Cookie: foo=bar; expires=Wednesday, 09-Nov-99 23:12:40 GMT

Domain

Set-Cookie: SHIPPING=FEDEX; domain="joes-hardware.com"

Path

Set-Cookie: lastorder=00183; path=/orders

Secure

Set-Cookie: private_id=519; secure

Secure: if this attribute is included, a cookie will be sent only if HTTP is using an SSL secure connection.

6.5.2 Version 1 (RFC 2965) Cookies

The RFC 2965 cookie standard is a bit more complicatead than the original Netscape standard and is not yet completely supported.

6.6 Cookies and Session Tracking

6.7 Cookies and Caching

You have to be careful when caching documents that are involved with cookie transactions.

Here are some guiding principles for dealing with caches:

  • Mark documents uncacheable if they are: Cache-Control: no-cache="Set-Cookie", Cache-Control: public

  • Be cautious about caching Set-Cookie headers:

6.8 Cookies, Security, and Privacy

Cookies themselves are not believed to be a tremendous security risk, because they can be disabled and because much of the tracking can be done through log analysis or other means.

If the user goes to , she will get only this cookie:

But if she goes to , she will get both of these cookies:

http://www.airtravelbargains.com/specials.html
http://www.airtravelbargains.com/autos/cheapo/index.html