manual/en/features.cookies.php

20021201_rev01 · COMPARED WITH 20021001_rev01 · ARCHIVE SNAPSHOT, DATE APPROXIMATE

Full text changes — 20021001_rev01 to 20021201_rev01

1## Chapter 19. Cookies
1## Chapter 17. Cookies
22
33PHP transparently supports HTTP cookies. Cookies are a mechanism for storing data in the remote browser and thus tracking or identifying return users. You can set cookies using the [**setcookie()**](https://php.net/manual/en/function.setcookie.php) function. Cookies are part of the HTTP header, so [**setcookie()**](https://php.net/manual/en/function.setcookie.php) must be called before any output is sent to the browser. This is the same limitation that [**header()**](https://php.net/manual/en/function.header.php) has. You can use the [output buffering functions](https://php.net/manual/en/ref.outcontrol.php) to delay the script output until you have decided whether or not to set any cookies or send any headers.
44
55Any cookies sent to you from the client will automatically be turned into a PHP variable just like GET and POST method data, depending on the register\_globals and variables\_order configuration variables. If you wish to assign multiple values to a single cookie, just add _\[\]_ to the cookie name.
66
77In PHP 4.1.0 and later, the $\_COOKIE auto-global array will always be set with any cookies sent from the client. $HTTP\_COOKIE\_VARS is also set in earlier versions of PHP when the track\_vars configuration variable is set.
88
99For more details, including notes on browser bugs, see the [**setcookie()**](https://php.net/manual/en/function.setcookie.php) function.
1010
11<table><tbody><tr><td><small>User Contributed Notes</small><br><b>Cookies</b></td><td><a href="https://php.net/manual/add-note.php?sect=features.cookies&amp;redirect=http://www.php.net/manual/en/features.cookies.php"><img src="https://php.net/gifs/notes-add.gif" width="13" height="13" alt="add a note"></a>&nbsp;<a href="https://php.net/manual/about-notes.php"><img src="https://php.net/gifs/notes-about.gif" width="13" height="13" alt="about notes"></a></td></tr><tr><td colspan="2"><a name="#11858"></a><table><tbody><tr><td><b>yasuo_ohgaki at hotmail dot com</b><br>09-Mar-2001 09:58</td><td><br></td></tr><tr><td colspan="2"><code>It might be good idea that manual mentions related standard (RFC2965,RFC2109 for cookie, Netscape's cookie spec also) and URL for the standard.<p>Following link is for cookie definitions:<br><a href="http://portal.research.bell-labs.com/~dmk/cookie.html">http://portal.research.bell-labs.com/~dmk/cookie.html</a></p><p>It seems many users do not read standard definitions, unfortunately. Manual may need to be written to encourage users to read related standards.</p></code><br></td></tr></tbody></table></td></tr><tr><td colspan="2"><a name="#19014"></a></td></tr><tr><td colspan="2"><a href="https://php.net/manual/add-note.php?sect=features.cookies&amp;redirect=http://www.php.net/manual/en/features.cookies.php"><img src="https://php.net/gifs/notes-add.gif" width="13" height="13" alt="add a note"></a>&nbsp;<a href="https://php.net/manual/about-notes.php"><img src="https://php.net/gifs/notes-about.gif" width="13" height="13" alt="about notes"></a></td></tr></tbody></table>
11<table><tbody><tr><td><small>User Contributed Notes</small><br><b>Cookies</b></td><td><a href="https://php.net/manual/add-note.php?sect=features.cookies&amp;redirect=http://www.php.net/manual/en/features.cookies.php"><img src="https://php.net/gifs/notes-add.gif" width="13" height="13" alt="add a note"></a>&nbsp;<a href="https://php.net/manual/about-notes.php"><img src="https://php.net/gifs/notes-about.gif" width="13" height="13" alt="about notes"></a></td></tr><tr><td colspan="2"><a name="#11858"></a><table><tbody><tr><td><b>yasuo_ohgaki at hotmail dot com</b><br>09-Mar-2001 09:58</td><td><br></td></tr><tr><td colspan="2"><code>It might be good idea that manual mentions related standard (RFC2965,RFC2109 for cookie, &nbsp;Netscape's cookie spec also) and URL for the standard.<p>Following link is for cookie definitions:<br><a href="http://portal.research.bell-labs.com/~dmk/cookie.html">http://portal.research.bell-labs.com/~dmk/cookie.html</a></p><p>It seems many users do not read standard definitions, unfortunately. Manual may need to be written to encourage users to read related standards.</p></code><br></td></tr></tbody></table></td></tr><tr><td colspan="2"><a name="#19014"></a></td></tr><tr><td colspan="2"><a href="https://php.net/manual/add-note.php?sect=features.cookies&amp;redirect=http://www.php.net/manual/en/features.cookies.php"><img src="https://php.net/gifs/notes-add.gif" width="13" height="13" alt="add a note"></a>&nbsp;<a href="https://php.net/manual/about-notes.php"><img src="https://php.net/gifs/notes-about.gif" width="13" height="13" alt="about notes"></a></td></tr></tbody></table>