Cookies are small text files that sit on the client machine. Web pages with the right permissions can read from and write to cookies. They are generally used to track user information between visits.
In ColdFusion, cookies are set with the <cfcookie> tag, which takes several attributes.
|name||The cookie's name (required).|
|value||The cookie's value.|
|expires||The cookie's expiration date (if this isn't set, the cookie will expire when the browser window is closed).|
|secure||A flag indicating whether the cookie should only be read over https.|
|path||The directory path on the server that can read the cookie.|
|domain||The domain name that can read the cookie.|
The following code will set a cookie that expires in one week.
The following code will set a cookie that expires in on December 31, 2008.
The following code will set a cookie that never expires.
To delete a cookie, set the expiration date to now(), like this.