Setting Cookies
As explained on the previous page, the setcookie() function has many attributes. However only one is required, this is the name attribute.
<?php setcookie("CookieName"); ?>
The code above will set a cookie with the name CookieName, all cookies in PHP can be accessed using the $_COOKIE array. The syntax for this is as follows...
$_COOKIE['name']
You would replace name with the name of the cookie, so for our first example this would be CookieName, then you would use the echo function to print out the value...
<?php echo "{$_COOKIE['CookieName']}"; ?>
Remember: If you are using double quotes to echo things out, remember to place {} around anything which contains single quotes or PHP will generate an error.
This concludes our very basic introduction to PHP's cookie function setcookie(). You can find more information and examples on the PHP Manual.