Source of: /manual/en/features.cookies.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/features.inc";
$setup = array (
'home' =>
array (
0 => 'index.php',
1 => 'PHP Manual',
),
'head' =>
array (
0 => 'UTF-8',
1 => 'en',
),
'this' =>
array (
0 => 'features.cookies.php',
1 => 'Cookies',
),
'up' =>
array (
0 => 'features.php',
1 => 'Features',
),
'prev' =>
array (
0 => 'features.http-auth.php',
1 => 'HTTP authentication with PHP',
),
'next' =>
array (
0 => 'features.sessions.php',
1 => 'Sessions',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<div>
<h1>Cookies</h1>
<p class="para">
PHP transparently supports <acronym title="Hypertext Transfer Protocol">HTTP</acronym> 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 <a href="function.setcookie.php" class="function">setcookie()</a> or
<a href="function.setrawcookie.php" class="function">setrawcookie()</a>
function. Cookies are part of the <acronym title="Hypertext Transfer Protocol">HTTP</acronym> header, so
<a href="function.setcookie.php" class="function">setcookie()</a> must be called before any output is sent to
the browser. This is the same limitation that <a href="function.header.php" class="function">header()</a>
has. You can use the <a href="ref.outcontrol.php" class="link">output buffering
functions</a> to delay the script output until you have decided whether
or not to set any cookies or send any headers.
</p>
<p class="para">
Any cookies sent to you from the client will automatically be included into
a <var class="varname"><a href="reserved.variables.cookies.php" class="classname">$_COOKIE</a></var> auto-global
array if <a href="ini.core.php#ini.variables-order" class="link">variables_order</a>
contains "C". If you wish to assign multiple values to a single
cookie, just add <i>[]</i> to the cookie name.
</p>
<p class="para">
Depending on <a href="ini.core.php#ini.register-globals" class="link">register_globals</a>,
regular PHP variables can be created from cookies. However it's not
recommended to rely on them as this feature is often turned off for the
sake of security.
<var class="varname">$HTTP_COOKIE_VARS</var> is also set in earlier versions of PHP
when the <a href="ini.core.php#ini.track-vars" class="link">track_vars</a> configuration
variable is set. (This setting is always on since PHP 4.0.3.)
</p>
<p class="para">
For more details, including notes on browser bugs, see the
<a href="function.setcookie.php" class="function">setcookie()</a> and <a href="function.setrawcookie.php" class="function">setrawcookie()</a>
function.
</p>
</div>
<?php manual_footer(); ?>