Cookies

Team-Fly    

ColdFusion® MX: From Static to Dynamic in 10 Steps
By Barry Moore
Table of Contents
The Next Step: Advanced ColdFusion Functionality


Browser cookies were briefly mentioned in Step 8, "ColdFusion Application Framework." Cookies are not a feature of ColdFusion; rather, they are a feature of HTTP and the World Wide Web in general.

A cookie is simply a small text file placed on the user's computer by the web server. The information stored in that cookie is then available to the web server the next time the user returns to the web site. Consequently, this makes cookies an ideal place to store information, such as a user's name, color and content preferences, and the date of his last visit.

When a user requests a page from the web server, the server responds with the requested page but might also send commands to store a cookie on the user's hard drive. When a user requests another page from the same domain, the cookie is then passed back to the server as part of the request. The server can then process the information retrieved from the cookie.

Cookies have their own variable scope and are placed using the <CFSET> tag, as follows:

 <CFSET COOKIE.UserName="Barry">

Once set and retrieved, cookie information can be used just like any other variable, as follows:

 <CFOUTPUT>Welcome Back, #COOKIE.UserName#</CFOUTPUT>

For more information about cookies, visit the www.LearnColdFusionMX.com web site.


    Team-Fly    
    Top
     



    ColdFusion MX. From Static to Dynamic in 10 Steps
    ColdFusion MX: From Static to Dynamic in 10 Steps
    ISBN: 0735712964
    EAN: 2147483647
    Year: 2002
    Pages: 140
    Authors: Barry Moore

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net