ColdFusion Variable Types
|
Variable Type
|
Description
|
Queries
|
As soon as a query has been run, you can use its results as dynamic parameters. For example, if you create a query named LookupUser that finds the ID for a given user name, you might want to use this ID in another query or in a CFOUTPUT.
|
Local Variables
|
This is the default scope for variables created with the CFSET and CFPARAM tags. For example, <CFSET A=5> sets the variable A to 5. This variable is available only on the page where it is created and any included pages.
|
URL Parameters
|
Parameters appended to URLs after the application page name using a variablename=value format.
|
Form Fields
|
The most common way of passing parameters to a page is to use form fields. When a user enters data in a form field, a parameter with the name of the form field is passed to the action page.
|
Client
|
ColdFusion client variables are variables associated with a particular client. Client variables allow you to maintain state as a user moves from page to page in an application. They are stored in the system registry by default, but you can also choose to store them in a cookie or in a database.
For more information, see the Using the Application Framework chapter of this book.
|
Server
|
ColdFusion server variables are associated with the current Web server and are available to all ColdFusion applications until the ColdFusion server is shut down. This server scope allows you to define variables that all your ColdFusion application pages can reference.
|
Session
|
Session variables are tied to an individual client and persist for as long as that Client ID maintains a session. Session variables, like current client variables, require a client name to work and are only available to that Client ID.
Unlike client variables, session variables are stored in the server's memory and can be set to time-out after a precise period of inactivity.
|
Application
|
Application variables are tied to an individual application as defined in the CFAPPLICATION NAME attribute, typically used in the Application.cfm file. Application variables only work if an application name has been defined.
For more information about the Application.cfm file, see the Using the Application Framework chapter of this book.
|
HTTP Cookies
|
HTTP Cookie variables are stored in the browser. They are available every time the browser makes a page request. You can create cookie variables with the CFCOOKIE tag.
|
CGI Environment
|
Every page request has several environment variables sent to it that relate to the context in which it was requested. The variables available will depend on the browser and server software in use for a given request.
Note: CGI environment variables are created even when you are using one of the Web servers that supports a server API.
|