manual/en/features.cookies.php

20020805_rev01 · COMPARED WITH 20011225_rev01 · ARCHIVE SNAPSHOT, DATE APPROXIMATE

Full text changes — 20011225_rev01 to 20020805_rev01

1## Chapter 18. Cookies
1## Chapter 19. 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.
10
11<table><tbody><tr><td><small>User Contributed Notes<br></small><b>Cookies</b><br></td><td><a href="https://php.net/manual/add-note.php?sect=features.cookies&amp;redirect=http://download.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><br></td></tr><tr><td colspan="2"><a name="#11858"></a><table><tbody><tr><td><a href="mailto:yasuo_ohgaki@hotmail.com">yasuo_ohgaki@hotmail.com</a><br>09-Mar-2001 07:58</td><td><br></td></tr><tr><td colspan="2"><tt>It might be good idea that manual mentions related standard<br>(RFC2965,RFC2109 for cookie, Netscape's cookie spec also) and URL for the<br>standard.<p>Following link is for cookie definitions:<br>http://portal.research.bell-labs.com/~dmk/cookie.html</p><p>It seems many users do not read standard definitions, unfortunately. Manual<br>may need to be written to encourage users to read related standards.</p></tt><br></td></tr></tbody></table></td></tr><tr><td colspan="2"><a href="https://php.net/manual/add-note.php?sect=features.cookies&amp;redirect=http://download.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><br></td></tr></tbody></table>