philip Tue Jul 16 12:52:32 2002 EDT Modified files: /phpdoc/en/reference/http/functions setcookie.xml Log: * setcookie() returns true on success, false on failure. This does not imply the cookie was set or not. Closes bug #18287 * Made it clearer when autoglobal $_COOKIE became available, added links * Can set as array names, but they will set seperate cookies. Consider explode or serialize. * A few more words on "checking if cookie set" Index: phpdoc/en/reference/http/functions/setcookie.xml diff -u phpdoc/en/reference/http/functions/setcookie.xml:1.3 phpdoc/en/reference/http/functions/setcookie.xml:1.4 --- phpdoc/en/reference/http/functions/setcookie.xml:1.3 Sun Jun 16 03:11:03 2002 +++ phpdoc/en/reference/http/functions/setcookie.xml Tue Jul 16 12:52:32 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <!-- splitted from ./en/functions/http.xml, last change in rev 1.2 --> <refentry id="function.setcookie"> <refnamediv> @@ -9,7 +9,7 @@ <refsect1> <title>Description</title> <methodsynopsis> - <type>int</type><methodname>setcookie</methodname> + <type>boolean</type><methodname>setcookie</methodname> <methodparam><type>string</type><parameter>name</parameter></methodparam> <methodparam choice="opt"><type>string</type><parameter>value</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>expire</parameter></methodparam> @@ -23,7 +23,11 @@ <emphasis>before</emphasis> any other headers are sent (this is a restriction of cookies, not PHP). This requires you to place calls to this function before any <literal><html></literal> or - <literal><head></literal> tags. + <literal><head></literal> tags. If headers exist prior to + calling this function, <function>setcookie</function> will fail + and return &false;. If <function>setcookie</function> successfully + runs, it will return &true; This does not mean the user accepted + the cookie or not. </para> <para> All the arguments except the <parameter>name</parameter> argument @@ -42,9 +46,13 @@ only be transmitted over a secure HTTPS connection. </para> <para> - Once the cookies have been set they can be accessed on the next page load - with the <varname>$_COOKIE</varname> array (which used to be called - <varname>$HTTP_COOKIE_VARS</varname> in PHP versions prior to 4.1.0). + Once the cookies have been set, they can be accessed on the next page load + with the <link linkend="reserved.variables.cookies">$_COOKIE</link> or + <varname>$HTTP_COOKIE_VARS</varname> arrays. Note, + <link linkend="language.variables.superglobals">autoglobals</link> + such as <varname>$_COOKIE</varname> became available in PHP + <ulink url="&url.php.release4.1.0;">4.1.0</ulink>. + <varname>$HTTP_COOKIE_VARS</varname> has existed since PHP 3. </para> <para> Common Pitfalls: @@ -52,12 +60,24 @@ <listitem> <simpara> Cookies will not become visible until the next loading of a page that - the cookie should be visible for. + 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 <parameter>expire</parameter> + parameter. </simpara> </listitem> <listitem> <simpara> Cookies must be deleted with the same parameters as they were set with. + </simpara> + </listitem> + <listitem> + <simpara> + Cookies names can be set as array names and will be available to your + PHP scripts as arrays but seperate cookies are stored on the users + system. Consider <function>explode</function> or + <function>serialize</function> to set one cookie with multiple names + and values. </simpara> </listitem> </itemizedlist>
-- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php