Using Application Variables ColdFusion Help

Application variables are associated with a single application and are accessible by multiple clients. Specifically, they are tied to the application name specified in the CFAPPLICATION tag. To enable application variables, you must add a CFAPPLlCATION tag with a NAMEattribute to your applcation. cfm template.

Application variables, like session variables, also have a timeout period. The default timeout period (set in the ColdFusion Administrator) is two days. The timeout clock starts ticking when activity ceases between any client and the application. Application variables also expire if the ColdFusion server has been stopped. Like session variables, application variables are stored in the server’s RAM. Although this provides performance advantages (quick and easy access), it may limit the amount of information you should consider storing in an application variable. The amount of information you can store in application variables will depend on the amount of your server’s RAM.

Application variables can be used to store information needed for all clients of a particular application. Some typical reasons for using application variables include:
• Standardizing background colors, fonts, and other visual controls for all clients of a particular application
• Setting standards such as the application title, data sources, and e-mail contacts
• Keeping track of counts such as the number of products ordered, number of visitors, etc.
• Storing arrays that can be accessed by all clients instead of passing them between templates
• Storing query recordsets that can be accessed by all clients, as opposed to running a query multiple times.

Enabling Application Variables

Application variables are enabled by using the CFAPPLlCA TION tag in your Application cfm template. In the CFAPPLlCATION tag you must specify a name for your application using the NAMEattribute. You also have the option of setting the application timeout period using the APPLlCATIONTlMEOUT attribute. If you don’t specify a timeout period, the timeout will default to th~ttings in the ColdFusion Administrator. The following code shows the syntax of a CFAPPllCATION tag that has enabled application variables.

Using the CFAdministrator

You can use the ColdFusion Administrator to enable application variables as well as set their minimum and maximum timeout values. When you open the ColdFusion Administrator, select the Variables option under the Server section on the left-hand frame.

Enabling Session Management

Look at the third section of the ColdFusion Administrator Variables screen, titled Session and Application Variables. ‘This is where you can enable or disable the use of application variables on a server. H application variables are disabled, then application management cannot be used, even if you specify a CFAPPLICATION tag in an Application. cfm template. You may choose not to enable application variables to reduce the amount of strain you put on the server’s RAM (because application variables are stored in the server’s RAM).

Setting the Default and Maximum Timeout Values

In the Session and Application Variables section of the ColdFusion Administrator’s Variables screen, you can also specify default and maximum timeouts for application variables.
The default value applies to all applications on a particular server. Setting the APPLlCATIONTIMEOUT attribute of the CFAPPLICATION tag in a particular Application cfm template can overwrite.this default. The maximum value refers to the maximum timeout value allowed for any application on a particular server. ‘This cannot be overwritten or superseded by the APPLlCATIONTIMEOUT set in a CFAPPLlCATION tag. ColdFusion will not allow an application timeout period higher than the maximum set value. Setting a higher application timeout value in a particular application will cause ColdFusion to use the Administrator’s maximum timeout value.

Posted on November 16, 2015 in Implementing the coldFusion Web Application Framework

Share the Story

Back to Top
Share This