Brief notes on a really old version of cold fusion

Cold Fusion 3.1 Tips

Way back in the '90s I did some ColdFusion work - it was really fun and cutting edge at the time, ... but the world moves on.

  1. Setting a variable:
    <cfset #OK# = 'NOT_OK'>
    
  2. Logical branching:
    <cfif #MYCOUNT# EQ 0>
         statements...
    <cfelseif #MYCOUNT# GE 1>
          statements...
    <cfelse>
          statements...
    </cfif>
    

  3. Querys etc:
       <CFQUERY datasource="mydatabase" name="getpassword" 
       SQL="Select password from Passwords where password = '#PASSWORD#'">
       </CFQUERY>
       <cfif #getpassword.RecordCount# GT 0>
          <cfset #OK# = 'OK'>
       </cfif>
    
  4. Stuff info into database
    <CFQUERY datasource="mydatabase">
       Update mytable SET
            FirstName='#FirstName#',
            LastName='#LastName#',
       WHERE EmployeeID=#EmployeeID#
     </CFQUERY>
    
  5. to create a carriage return or other control character
    #CHR(013)#
    
  6. Goto another page:
    <CFLOCATION URL="NewPage.cfm" ADDTOKEN="No">
    
  7. Check for the existance of a variable (great for detecting if a checkbox has been checked):
    <CFIF IsDefined("InState")>
       <cfset #InState# = 1>
    <cfelse>
       <cfset #InState# = 0>
    </CFIF>
    
  8. Call a stored procedure:
    <cfquery datasource="mydatabase" name="mystoredp">
         { CALL sp_mystoredproc ('#NAME#') }
    </CFQUERY>
    
  9. Get the current file's name
    <cfset #CURRENTFILE# = #GetFileFromPath(GetTemplatePath())#>
    
  10. Use cookies

    This sets a cookie that will expire in 100 days. If the expires field is omitted, the cookie expires at the end of the session.

         <CFCOOKIE NAME="color" VALUE="red" EXPIRES="100">
    

    This sets the value of a cookie

         <cfset #Cookie.color# = "green">
    

    This prints the value of a cookie

         <cfoutput>value of cookie color is #Cookie.color#</cfoutput>
    
    Wierd fact about ColdFusion: If a CFLOCATION is done on the same page, the setting of a cookie value does NOT take place.