downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

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 &quot;C&quot;. 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&#039;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(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites