ZCE # Week # 261


Fill in the blank with the appropriate function name. Do not add parenthesis.

The _____________ function is used to set a cookie to be sent along with the rest of the HTTP headers.


A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too.

The setcookie() function is used to set a cookie.

Like other headers, cookies must be send before any output from your script. This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any white space.

Once the cookies have been set, they can be accessed on the next page load with the $_COOKIE or $HTTP_COOKIE_VARS arrays.

Cookies values also exists in $_REQUEST.

The value of the cookie is automatically URL encoded when sending the cookie, and automatically decoded when received.

The setrawcookie() function sends a cookie without urlencoding the cookie value.

The setrawcookie() is exactly the same as setcookie() except that the cookie value will not be automatically urlencoded when sent to the browser.

When deleting a cookie you should assure that the expiration date is in the past.

Answer: setcookie