![]() ![]() ![]() |
||
|
Client variables let you store user information and preferences between sessions. Using information from client variables, you can customize page content for individual users.
You enable client variable default settings in ColdFusion MX on the Client Variables page of the Administrator. ColdFusion MX lets you store client variables in the following ways:
Note: If your data source uses one of the JDBC drivers bundled with ColdFusion MX 7, ColdFusion MX can automatically create the necessary tables. If your data source uses the ODBC Socket or a third-party JDBC driver, you must manually create the necessary CDATA and CGLOBAL database tables.
Caution: Macromedia recommends that you do not store client variables in the registry because it can critically degrade performance of the server. If you do use the registry to store client variables, you must allocate sufficient memory and disk space.
You can override settings specified in the Client Variables page using the Application.cfc file or the cfapplication
tag. For more information, see ColdFusion MX Developers Guide.
The following table compares the client variable storage options:
Storage type |
Advantages |
Disadvantages |
---|---|---|
Data source |
|
|
Browser cookies |
|
|
System registry |
|
|
To migrate your client variable data to another data source, you should know the structure of the database tables that store this information. Client variables stored externally use two simple database tables, like those shown in the following tables:
CDATA Table |
|
---|---|
Column |
Data type |
cfid |
CHAR(64), TEXT, VARCHAR, or equivalent |
app |
CHAR(64), TEXT, VARCHAR, or equivalent |
data |
MEMO, LONGTEXT, LONG VARCHAR, or equivalent |
CGLOBAL Table |
|
---|---|
Column |
Data type |
cfid |
CHAR(64), TEXT, VARCHAR, or equivalent |
data |
MEMO, LONGTEXT, LONG VARCHAR, or equivalent |
lvisit |
TIMESTAMP, DATETIME, DATE, or equivalent |
Use the following sample ColdFusion page as a model for creating client variable database tables in your own database. However, keep in mind that not all databases support the same column data type names. For the proper data type, see your database documentation.
Tip: The ColdFusion MX Administrator can create client variable tables for data sources that use one of the bundled JDBC drivers. For more information, see the online help.
<!---- Create the Client variable storage tables in a datasource. This example applies to Microsoft Access databases. ---> <cfquery name="data1" datasource="#DSN#"> CREATE TABLE CDATA ( cfid char(20), app char(64), data memo ) </cfquery> <cfquery name="data2" datasource="#DSN#"> CREATE UNIQUE INDEX id1 ON CDATA (cfid,app) </cfquery> <cfquery name="global1" datasource="#DSN#"> CREATE TABLE CGLOBAL ( cfid char(20), data memo, lvisit date ) </cfquery> <cfquery name="global2" datasource="#DSN#"> CREATE INDEX id2 ON CGLOBAL (cfid) </cfquery> <cfquery name="global2" datasource="#DSN#"> CREATE INDEX id3 ON CGLOBAL (lvisit) </cfquery>
|
||
![]() ![]() ![]() |