services


gallery


tutorials


process


contact


links

Gallery:  ColdFusion ASP PHP Shootout

ColdFusion

ASP

PHP

Cookies

ColdFusion

The <CFCOOKIE> tag is used to create cookies on the browser. Existing cookies are accessed by simply adding "COOKIE." to the name of the cookie, e.g. COOKIE.MyCookie1.



ASP

There are two cookies collections in ASP. You use the one in the Response object to create and modify cookies and the one in the Request object to get cookie information from the browser.



PHP

Use the setcookie() function to send a request to the browser to create or update a cookie. This code must appear at the very start of the page. Any content, even whitespace, preceding the opening PHP tag will generate an error because that content will automatically be sent to the browser, thus necessitating the header for the page to be sent. Later when you want to send the cookie, which has to go with the header, PHP will find that the header was already sent and generate an error informing you of that fact. Note that if you have turned off error messages, this problem could be hard to diagnose.

On startup of a script, cookies are automatically made available as global variables referenced by the cookie name. For example, if there is a cookie named username, then the variable $username would contain the value of that cookie.



Copyright © 2005 Cyberglitz

email: info@cyberglitz.com