You should avoid creating the names of variables (except for dot notation in structures) that include periods. However, ColdFusion provides mechanisms for handling cases where you must do so, for example, to maintain compatibility with names of variables in external data sources or to integrate your application with existing code that uses periods in variable names. The following sections describe how to create simple variable names that include periods.
Using brackets to create variables with periods
You can create a variable name that includes periods by using associative array structure notation, as described in Structure notation. To do so, you must do the following:
The following example shows this technique:
<cfset Variables['My.Variable.With.Periods'] = 12> <cfset Request["Another.Variable.With.Periods"] = "Test variable"> <cfoutput> My.Variable.With.Periods is: #My.Variable.With.Periods#<br> Request.Another.Variable.With.Periods is: #Request.Another.Variable.With.Periods#<br> </cfoutput>
Creating Client and Cookie variables with periods
To create a Client or Cookie variable with a name that includes one or more periods, simply assign the variable a value. For example, the following line creates a Cookie named User.Preferences.CreditCard:
<cfset Cookie.User.Preferences.CreditCard="Discover">