diff --git a/functions/http.xml b/functions/http.xml index 105b24c392..e801bc6ad8 100644 --- a/functions/http.xml +++ b/functions/http.xml @@ -121,11 +121,11 @@ header ("Pragma: no-cache"); // HTTP/1.0 int setcookie string name - string value - int expire - string path - string domain - int secure + string value + int expire + string path + string domain + int secure @@ -152,13 +152,22 @@ header ("Pragma: no-cache"); // HTTP/1.0 secure indicates that the cookie should only be transmitted over a secure HTTPS connection. - + Common Pitfalls: + + + + Cookies will not become visible until the next loading of a page that + the cookie should be visible for. + + + + + Cookies must be deleted with the same parameters as they were set with. + + + - - Cookies will not become visible until the next loading of a page that - the cookie should be visible for. - In PHP3, multiple calls to setcookie in the same script will be performed in reverse order. If you are trying to @@ -167,9 +176,9 @@ header ("Pragma: no-cache"); // HTTP/1.0 setcookie are performed in the order called. - Some examples follow: + Some examples follow how to send cookies: - <function>setcookie</function> examples + <function>setcookie</function> send examples setcookie ("TestCookie", "Test Value"); setcookie ("TestCookie", $value,time()+3600); /* expire in 1 hour */ @@ -177,6 +186,17 @@ setcookie ("TestCookie", $value,time()+3600, "/~rasmus/", ".utoronto.ca", 1); + + Examples follow how to delete cookies send in previous example: + + <function>setcookie</function> delete examples + +setcookie ("TestCookie"); +setcookie ("TestCookie", "",time()); +setcookie ("TestCookie", "",time(), "/~rasmus/", ".utoronto.ca", 1); + + + Note that the value portion of the cookie will automatically be urlencoded when you send the cookie, and when it is received, it