<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.network.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.setcookie.php',
    1 => 'setcookie',
    2 => 'Send a cookie',
  ),
  'up' => 
  array (
    0 => 'ref.network.php',
    1 => 'Network Functions',
  ),
  'prev' => 
  array (
    0 => 'function.request-parse-body.php',
    1 => 'request_parse_body',
  ),
  'next' => 
  array (
    0 => 'function.setrawcookie.php',
    1 => 'setrawcookie',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/network/functions/setcookie.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.setcookie" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">setcookie</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">setcookie</span> &mdash; <span class="dc-title">Send a cookie</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.setcookie-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>setcookie</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$name</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$value</code><span class="initializer"> = &quot;&quot;</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$expires_or_options</code><span class="initializer"> = 0</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$path</code><span class="initializer"> = &quot;&quot;</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$domain</code><span class="initializer"> = &quot;&quot;</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$secure</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$httponly</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span><br>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="simpara">Alternative signature available as of PHP 7.3.0 (not supported with named parameters):</p>
  <div class="methodsynopsis dc-description"><span class="methodname"><strong>setcookie</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$name</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$value</code><span class="initializer"> = &quot;&quot;</span></span>, <span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$options</code><span class="initializer"> = []</span></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="simpara">
   <span class="function"><strong>setcookie()</strong></span> defines a cookie to be sent along with the
   rest of the HTTP headers. Like other headers, cookies must be sent
   <em>before</em> any output from the script (this is a
   protocol restriction). This requires that this function is called
   prior to any output, including <code class="literal">&lt;html&gt;</code> and
   <code class="literal">&lt;head&gt;</code> tags as well as any whitespace.
  </p>
  <p class="simpara">
   Once the cookies have been set, they can be accessed on the next page load
   with the <var class="varname"><a href="reserved.variables.cookies.php" class="classname">$_COOKIE</a></var> array.
   Cookie
   values may also exist in <var class="varname"><a href="reserved.variables.request.php" class="classname">$_REQUEST</a></var>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.setcookie-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <a href="https://datatracker.ietf.org/doc/html/rfc6265" class="link external">&raquo;&nbsp;RFC 6265</a> provides the normative
   reference on how each <span class="function"><strong>setcookie()</strong></span> parameter is
   interpreted.
   <dl>
    
     <dt><code class="parameter">name</code></dt>
     <dd>
      <span class="simpara">
       The name of the cookie.
      </span>
     </dd>
    
    
     <dt><code class="parameter">value</code></dt>
     <dd>
      <span class="simpara">
       The value of the cookie.  This value is stored on the clients computer;
       do not store sensitive information.  Assuming the
       <code class="parameter">name</code> is <code class="literal">&#039;cookiename&#039;</code>, this
       value is retrieved through <var class="varname"><a href="reserved.variables.cookies.php" class="classname">$_COOKIE['cookiename']</a></var>
      </span>
     </dd>
    
    
     <dt><code class="parameter">expires_or_options</code></dt>
     <dd>
      <span class="simpara">
       The time the cookie expires.  This is a Unix timestamp so is
       in number of seconds since the epoch.
       One way to set this is by adding the number of seconds before the cookie
       should expire to the result of calling <span class="function"><a href="function.time.php" class="function">time()</a></span>.
       For instance, <code class="literal">time()+60*60*24*30</code> will set the cookie to
       expire in 30 days.
       Another option is to use the <span class="function"><a href="function.mktime.php" class="function">mktime()</a></span> function.
       If set to <code class="literal">0</code>, or omitted, the cookie will expire at
       the end of the session (when the browser closes).
      </span>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <span class="simpara">
        The <code class="parameter">expires_or_options</code> parameter takes a
        Unix timestamp, as opposed to the date format <code class="literal">Wdy, DD-Mon-YYYY
        HH:MM:SS GMT</code>, because PHP does this conversion
        internally.
       </span>
      </p></blockquote>
     </dd>
    
    
     <dt><code class="parameter">path</code></dt>
     <dd>
      <span class="simpara">
       The path on the server in which the cookie will be available on.
       If set to <code class="literal">&#039;/&#039;</code>, the cookie will be available
       within the entire <code class="parameter">domain</code>.  If set to
       <code class="literal">&#039;/foo/&#039;</code>, the cookie will only be available
       within the <code class="literal">/foo/</code> directory and all
       sub-directories such as <code class="literal">/foo/bar/</code> of
       <code class="parameter">domain</code>.  The default value is the
       current directory that the cookie is being set in.
      </span>
     </dd>
    
    
     <dt><code class="parameter">domain</code></dt>
     <dd>
      <span class="simpara">
       The (sub)domain that the cookie is available to. Setting this to a
       subdomain (such as <code class="literal">&#039;www.example.com&#039;</code>) will make the
       cookie available to that subdomain and all other sub-domains of it (i.e.
       w2.www.example.com). To make the cookie available to the whole domain
       (including all subdomains of it), simply set the value to the domain
       name (<code class="literal">&#039;example.com&#039;</code>, in this case).
      </span>
      <span class="simpara">
       Older browsers still implementing the deprecated
       <a href="https://datatracker.ietf.org/doc/html/rfc2109" class="link external">&raquo;&nbsp;RFC 2109</a> may require a leading
       <code class="literal">.</code> to match all subdomains.
      </span>
     </dd>
    
    
     <dt><code class="parameter">secure</code></dt>
     <dd>
      <span class="simpara">
       Indicates that the cookie should only be transmitted over a
       secure HTTPS connection from the client. When set to <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, the
       cookie will only be set if a secure connection exists.
       On the server-side, it&#039;s on the programmer to send this
       kind of cookie only on secure connection (e.g. with respect to
       <var class="varname"><a href="reserved.variables.server.php" class="classname">$_SERVER["HTTPS"]</a></var>).
      </span>
     </dd>
    
    
     <dt><code class="parameter">httponly</code></dt>
     <dd>
      <span class="simpara">
       When <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> the cookie will be made accessible only through the HTTP
       protocol. This means that the cookie won&#039;t be accessible by
       scripting languages, such as JavaScript. It has been suggested that
       this setting can effectively help to reduce identity theft through
       XSS attacks (although it is not supported by all browsers), but that
       claim is often disputed.
       <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>
      </span>
     </dd>
    
    
     <dt><code class="parameter">options</code></dt>
     <dd>
      <span class="simpara">
       An associative <span class="type"><a href="language.types.array.php" class="type array">array</a></span> which may have any of the keys
       <code class="literal">expires</code>, <code class="literal">path</code>, <code class="literal">domain</code>,
       <code class="literal">secure</code>, <code class="literal">httponly</code> and <code class="literal">samesite</code>.
      </span>
      <span class="simpara">
       The values have the same meaning as described for the
       parameters with the same name. The value of the <code class="literal">samesite</code>
       element should be either <code class="literal">None</code>, <code class="literal">Lax</code>
       or <code class="literal">Strict</code>.
       If any of the allowed options are not given, their default values are the
       same as the default values of the explicit parameters. If the
       <code class="literal">samesite</code> element is omitted, no SameSite cookie
       attribute is set.
      </span>

      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <span class="simpara">
        To set a cookie that includes attributes that aren&#039;t among the keys listed,
        use <span class="function"><a href="function.header.php" class="function">header()</a></span>.
       </span>
      </p></blockquote>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <span class="simpara">
        If <code class="literal">samesite</code> is <code class="literal">&quot;None&quot;</code> then
        <code class="literal">secure</code> must also be enabled or the cookie will be
        blocked by the client.
       </span>
      </p></blockquote>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.setcookie-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="simpara">
   If output exists prior to calling this function,
   <span class="function"><strong>setcookie()</strong></span> will fail and return <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>. If
   <span class="function"><strong>setcookie()</strong></span> successfully runs, it will return <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.
   This does not indicate whether the user accepted the cookie.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.setcookie-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="simpara">
   If the <code class="parameter">options</code> array contains unsupported keys:
  </p>
  <ul class="itemizedlist">
   <li class="listitem">
    <span class="simpara">
     Prior to PHP 8.0.0, an <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> was generated.
    </span>
   </li>
   <li class="listitem">
    <span class="simpara">
     As of PHP 8.0.0, a <span class="exceptionname"><a href="class.valueerror.php" class="exceptionname">ValueError</a></span> is thrown.
    </span>
   </li>
  </ul>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.setcookie-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.2.0</td>
      <td>
       The date format of the cookie is now <code class="literal">&#039;D, d M Y H:i:s \G\M\T&#039;</code>;
       previously it was <code class="literal">&#039;D, d-M-Y H:i:s T&#039;</code>.
      </td>
     </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       Passing unsupported keys now throws a <span class="exceptionname"><a href="class.valueerror.php" class="exceptionname">ValueError</a></span>
       instead of emitting an <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong>.
      </td>
     </tr>

     <tr>
      <td>7.3.0</td>
      <td>
       An alternative signature supporting an <code class="parameter">options</code>
       array has been added. This signature supports also setting of the
       SameSite cookie attribute.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.setcookie-examples">
  <h3 class="title">Examples</h3>
  <p class="simpara">
   The effects of the following examples can be observed using the browser
   developer tools cookie list (usually in the Storage or Application tab).
  </p>
  <div class="example" id="example-1">
   <p><strong>Example #1 <span class="function"><strong>setcookie()</strong></span> send example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$value </span><span style="color: #007700">= </span><span style="color: #DD0000">'something from somewhere'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Set a "session cookie" that expires when the browser is closed<br /></span><span style="color: #0000BB">setcookie</span><span style="color: #007700">(</span><span style="color: #DD0000">"TestCookie"</span><span style="color: #007700">, </span><span style="color: #0000BB">$value</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">// Set a cookie that expires in 1 hour<br /></span><span style="color: #0000BB">setcookie</span><span style="color: #007700">(</span><span style="color: #DD0000">"TestCookie"</span><span style="color: #007700">, </span><span style="color: #0000BB">$value</span><span style="color: #007700">, </span><span style="color: #0000BB">time</span><span style="color: #007700">()+</span><span style="color: #0000BB">3600</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">// Set a cookie that applies only to a specific path on a specific domain<br />// Note that the domain used should match the site domain<br /></span><span style="color: #0000BB">setcookie</span><span style="color: #007700">(</span><span style="color: #DD0000">"TestCookie"</span><span style="color: #007700">, </span><span style="color: #0000BB">$value</span><span style="color: #007700">, </span><span style="color: #0000BB">time</span><span style="color: #007700">()+</span><span style="color: #0000BB">3600</span><span style="color: #007700">, </span><span style="color: #DD0000">"/~rasmus/"</span><span style="color: #007700">, </span><span style="color: #DD0000">"example.com"</span><span style="color: #007700">, </span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
  <p class="simpara">
   Note that the value portion of the cookie will automatically be
   urlencoded and decoded by PHP. This can be avoided by using
   <span class="function"><a href="function.setrawcookie.php" class="function">setrawcookie()</a></span> instead.
  </p>
  <p class="simpara">
   To see the contents of the cookies set in the above example on a later
   request:
  </p>
  <div class="informalexample">
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Print an individual cookie<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$_COOKIE</span><span style="color: #007700">[</span><span style="color: #DD0000">"TestCookie"</span><span style="color: #007700">];<br /><br /></span><span style="color: #FF8000">// Another way to debug/test is to view all cookies<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$_COOKIE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
  <div class="example" id="example-2">
   <p><strong>Example #2 <span class="function"><strong>setcookie()</strong></span> delete example</strong></p>
   <div class="example-contents"><p>
    To delete a cookie set the expiration date to a value in the past
    (but not zero, which is reserved for session cookies).
   </p></div>
   <div class="example-contents"><p>
    To delete the cookies set in previous example:
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// set the expiration date to one hour ago<br /></span><span style="color: #0000BB">setcookie</span><span style="color: #007700">(</span><span style="color: #DD0000">"TestCookie"</span><span style="color: #007700">, </span><span style="color: #DD0000">""</span><span style="color: #007700">, </span><span style="color: #0000BB">time</span><span style="color: #007700">() - </span><span style="color: #0000BB">3600</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">setcookie</span><span style="color: #007700">(</span><span style="color: #DD0000">"TestCookie"</span><span style="color: #007700">, </span><span style="color: #DD0000">""</span><span style="color: #007700">, </span><span style="color: #0000BB">time</span><span style="color: #007700">() - </span><span style="color: #0000BB">3600</span><span style="color: #007700">, </span><span style="color: #DD0000">"/~rasmus/"</span><span style="color: #007700">, </span><span style="color: #DD0000">"example.com"</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
  <div class="example" id="example-3">
   <p><strong>Example #3 <span class="function"><strong>setcookie()</strong></span> and arrays</strong></p>
   <div class="example-contents"><p>
    An &quot;array of cookies&quot; can be set by using array notation in the
    cookie name. This has the effect of setting as many cookies as
    there are array elements, but when the cookie is received by the
    script, the values are all placed in an array with the cookie&#039;s
    name:
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// set the cookies<br /></span><span style="color: #0000BB">setcookie</span><span style="color: #007700">(</span><span style="color: #DD0000">"cookie[three]"</span><span style="color: #007700">, </span><span style="color: #DD0000">"cookiethree"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">setcookie</span><span style="color: #007700">(</span><span style="color: #DD0000">"cookie[two]"</span><span style="color: #007700">, </span><span style="color: #DD0000">"cookietwo"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">setcookie</span><span style="color: #007700">(</span><span style="color: #DD0000">"cookie[one]"</span><span style="color: #007700">, </span><span style="color: #DD0000">"cookieone"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// after the page reloads, print them out<br /></span><span style="color: #007700">if (isset(</span><span style="color: #0000BB">$_COOKIE</span><span style="color: #007700">[</span><span style="color: #DD0000">'cookie'</span><span style="color: #007700">])) {<br />    foreach (</span><span style="color: #0000BB">$_COOKIE</span><span style="color: #007700">[</span><span style="color: #DD0000">'cookie'</span><span style="color: #007700">] as </span><span style="color: #0000BB">$name </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$value</span><span style="color: #007700">) {<br />        </span><span style="color: #0000BB">$name </span><span style="color: #007700">= </span><span style="color: #0000BB">htmlspecialchars</span><span style="color: #007700">(</span><span style="color: #0000BB">$name</span><span style="color: #007700">);<br />        </span><span style="color: #0000BB">$value </span><span style="color: #007700">= </span><span style="color: #0000BB">htmlspecialchars</span><span style="color: #007700">(</span><span style="color: #0000BB">$value</span><span style="color: #007700">);<br />        echo </span><span style="color: #DD0000">"</span><span style="color: #0000BB">$name</span><span style="color: #DD0000"> : </span><span style="color: #0000BB">$value</span><span style="color: #DD0000"> &lt;br /&gt;\n"</span><span style="color: #007700">;<br />    }<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>The above example will output:</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">three : cookiethree
two : cookietwo
one : cookieone</pre>
</div>
   </div>
  </div>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    Using separator characters such as <code class="literal">[</code> and <code class="literal">]</code>
    as part of the cookie name is not compliant to RFC 6265, section 4, but supposed
    to be supported by user agents according to RFC 6265, section 5.
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 notes" id="refsect1-function.setcookie-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    Output buffering can be used to allow script output prior to the
    call of this function. All output will be buffered until it is flushed
    (either explicitly or at the end of the script execution). This is done
    by calling <span class="function"><a href="function.ob-start.php" class="function">ob_start()</a></span> and
    <span class="function"><a href="function.ob-end-flush.php" class="function">ob_end_flush()</a></span> in the script, or setting the
    <code class="literal">output_buffering</code> configuration directive on in the
    <var class="filename">php.ini</var> or server configuration files.
   </span>
  </p></blockquote>
  <p class="para">
   Common Pitfalls:
   <ul class="itemizedlist">
    <li class="listitem">
     <span class="simpara">
      Cookies will not become visible until the next loading of a page that
      the cookie should be visible for.  To test if a cookie was successfully
      set, check for the cookie on a next loading page before the cookie
      expires.  Expire time is set via the <code class="parameter">expires_or_options</code>
      parameter.  A nice way to debug the existence of cookies is by
      simply calling <code class="literal">print_r($_COOKIE);</code>.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      Cookies must be deleted with the same parameters as they were set with.
      If the <code class="parameter">value</code> argument is an empty string, and all other arguments
      match a previous call to <span class="function"><strong>setcookie()</strong></span>, then the cookie with the specified
      name will be deleted from the remote client.
      This is internally achieved by setting value to <code class="literal">&#039;deleted&#039;</code> and expiration
      time in the past.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      Because setting a cookie with a value of <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> will try to delete the cookie,
      boolean values should not be used. Instead, use <em>0</em> for <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>
      and <em>1</em> for <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      Cookies names can be set as array names and will be available to the
      PHP scripts as arrays but separate cookies are stored by the browser.
      Consider <span class="function"><a href="function.json-encode.php" class="function">json_encode()</a></span> to set one cookie with multiple
      names and values. It is not recommended to use <span class="function"><a href="function.serialize.php" class="function">serialize()</a></span>
      for this purpose because it can result in security holes.
     </span>
    </li>
   </ul>
  </p>
  <p class="simpara">
   Multiple calls to <span class="function"><strong>setcookie()</strong></span> are performed in the order called.
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.setcookie-seealso">
  <h3 class="title">See Also</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.header.php" class="function" rel="rdfs-seeAlso">header()</a> - Send a raw HTTP header</span></li>
   <li><span class="function"><a href="function.setrawcookie.php" class="function" rel="rdfs-seeAlso">setrawcookie()</a> - Send a cookie without urlencoding the cookie value</span></li>
   <li><a href="features.cookies.php" class="link">cookies section</a></li>
   <li><a href="https://datatracker.ietf.org/doc/html/rfc6265" class="link external">&raquo;&nbsp;RFC 6265</a></li>
   <li><a href="https://datatracker.ietf.org/doc/html/rfc2109" class="link external">&raquo;&nbsp;RFC 2109</a></li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>