blob: 3c3548e2b0a74123485f61e2a4045fc7de566973 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
---
title: Cookie
slug: Web/HTTP/Headers/Cookie
tags:
- Cookies
- HTTP
- Reference
- header
- request
---
<div>{{HTTPSidebar}}</div>
<p><strong><code>Cookie</code></strong> 是 HTTP 請求標頭,它的值包含由伺服器設定的 <a href="/en-US/docs/Web/HTTP/Cookies">HTTP cookies</a> (透過 {{HTTPHeader("Set-Cookie")}} 標頭設定,或者透過 Javascript 的 {{domxref("Document.cookie")}} 設定)。</p>
<p><code>Cookie</code> 標頭不是必要的,比如瀏覽器可能會因為隱私設定而直接省略 Cookie 不傳。</p>
<table class="properties">
<tbody>
<tr>
<th scope="row">Header type</th>
<td>{{Glossary("Request header")}}</td>
</tr>
<tr>
<th scope="row">{{Glossary("Forbidden header name")}}</th>
<td>yes</td>
</tr>
</tbody>
</table>
<h2 id="Syntax">Syntax</h2>
<pre class="brush: html">Cookie: <cookie-list>
Cookie: name=value
Cookie: name=value; name2=value2; name3=value3</pre>
<dl>
<dt><cookie-list></dt>
<dd>一連串名值對(name-value pair),格式為: <code><cookie-name>=<cookie-value></code>。每對之間由一個分號與一個空白分隔(<code>'; '</code>)。</dd>
</dl>
<h2 id="Examples">範例</h2>
<pre>Cookie: PHPSESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1</pre>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Title</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{RFC("6265", "Cookie", "5.4")}}</td>
<td>HTTP State Management Mechanism</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{Compat("http.headers.Cookie")}}</p>
<h2 id="See_also">See also</h2>
<ul>
<li>{{HTTPHeader("Set-Cookie")}}</li>
<li>{{domxref("Document.cookie")}}</li>
</ul>
|