User Guide
Configuring and Using Client Variables 225
The following example shows how to use the cfparam tag to check for the existence
of a client parameter and to set a default value if the parameter does not already
exist:
<cfparam name="Client.FavoriteColor" default="Red">
Accessing and changing Client variables
You use the same syntax to access a Client variable as other types of variables. You
can use Client variables anywhere other ColdFusion variables are used.
To display the favorite color that has been set for a specific user, use the following
code:
<cfoutput>
Your favorite color is #Client.FavoriteColor#.
</cfoutput>
Standard Client variables
The Client scope has six built-in, read-only variables that your application can use:
You can use the
Client.HitCount and time information variables in customizing
behavior, depending on how often users visit your site and when they last visited. For
example, the following code shows the date of a user’s last visit to your site:
<cfoutput>
Welcome back to the Web SuperShop. Your last
visit was on #DateFormat(Client.LastVisit)#.
</cfoutput>
Variable Description
Client.CFID
The client ID, normally stored on the client system as a
cookie.
Client.CFToken
The client security token, normally stored on the client system
as a cookie.
Client.URLToken
A combination of the CFID and CFToken in the form
CFID=IDNum&CFTOKEN=tokenNum. This variable is useful if the
client does not support cookies and you must pass the
CFID
and
CFToken variables from page to page.
Client.HitCount
The number of page requests made by the client.
Client.LastVisit
The last time the client visited the application.
Client.TimeCreated
The time the CFID and CFToken variables that identify the
client to ColdFusion were first created.