Sie sind auf Seite 1von 4

Kinds of ColdFusion Variables:

Kind of Variable 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 can use this ID in another query or in a call to
CFOUTPUT.
Reference: queryName.variableName
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.
Reference: vLocalVariable
URL Parameters Parameters appended to URLs after the application page name
using a variablename=value format. URL parameters are
stored in structures. See Variables stored in structures for
more details.
Reference: url.variableName
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. Form fields are stored in structures. See
Variables stored in structures for more information.
Reference: Form.variableName
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. Client
variables are part of the ColdFusion Web Application
Framework. For more information about client variables in
this context, see Developing Web Applications with
ColdFusion.
Reference: client.variableName
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. Server variables are stored in
structures. See Variables stored in structures for more
information. For information on locking server variables, see
the description of CFLOCK in CFML Language Reference.
Reference: server.variableName
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.
Session variables are stored in structures. See Variables stored
in structures for more details. Session variables should be
locked when accessed. For information on locking session
variables, see the description of CFLOCK. Session variables
are part of the ColdFusion Web Application Framework. This
means that they are used in the context of an Application.cfm
page. For more information about session variables in this
context, see Developing Web Applications with ColdFusion
and the description of the CFAPPLICATION tag.
Reference: session.variableName
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. Application
variables are stored in structures. See Variables stored in
structures for more information. Application variables should
be locked when accessed. For information on locking session
variables, see the description of CFLOCK in CFML Language
Reference. Application variables are part of the ColdFusion
Web Application Framework. This means that they are used
in the context of an Application.cfm page. For more
information about session variables in this context,
Developing Web Applications with ColdFusion and the
description of the CFAPPLICATION tag.
Reference: application.variableName
Request Request variables store data that pertains to the processing of
a single page request. They are a convenient way to store data
in a structure, carried through nested tags, such as Custom
Tags, and processed at once. Request variables are stored in
structures. See Variables stored in structures for more
information.
Reference: request.variableName
Caller Caller variables let you call and use variables from the calling
template in a ColdFusion custom tag.
Reference:
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.
Reference: cookie.variableName
File File variables are read-only. These variables are created when
a CFFILE ACTION=UPLOAD operation is executed.
Reference: cffile.variableName
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.
Reference: cgi.variableName

Order of ColdFusion variable look-ups

When scoping is not used, that is, when you don't include a variable prefix, such as
"Form.myformvar," ColdFusion attempts to find variables in the following order:

1.Local variables created using CFSET and CFQUERY


2.CGI variables
3.File variables
4.URL variables
5.Form variables
6.Cookie variables
7.Client variables

Note
ColdFusion does not attempt to automatically find Application, Session, Server, and
Request variables, nor does it try to find CFML tag variables, with the exception of File
variables. You must use prefixes with these variables.
.

Variables across application pages


Within ColdFusion, most variables apply only to a single template. However, several
types of variables can be used across multiple application pages:

• Client variables store identifying information about an individual client.


Client variables are designed to hold long-term information particular to an individual
client. You can store client variables in the system registry, a database, or in a cookie
named for the application.
• Server variables are valid for all ColdFusion applications on a particular server.
Server variables are used to store information (typically read-only) that does not
change often and can be shared across many users and ColdFusion applications.
• Session variables are valid for as long as an individual Client ID maintains a session.
Session variables are useful for storing short-term information needed for a single site
visit or set of requests. They are specific to individual users.
• Application variables are valid for a specified application.
Application variables are available to individual, specified applications and to all
users of that application who access your ColdFusion server. They are stored in the
server's memory and can be set to time out at specified intervals. Application
variables are general and available to all users.
• Caller variables are valid for ColdFusion custom tags.
Caller variables are available for passing information among application pages for a
ColdFusion custom tag.

Das könnte Ihnen auch gefallen