CLIENT VariablesLike COOKIE and SESSION variables, CLIENT variables are specific to one user. However, rather than being stored on the client machine or in the server's memory, CLIENT variables are stored elsewhere. CLIENT variables can store only simple data (like numbers and strings), not complex data (like arrays, structures, and queries). Preparing CLIENT Variable StorageCLIENT variables, like SESSION variables, are also tied to an application and must be enabled before they can be used:
There are three locations where you can store CLIENT variables. They are discussed in Table 11.2 and can be set in the ColdFusion Administrator.
CAUTION Your system can become unstable or unusable if your registry holds too much data. As a general rule, registry use should be avoided. If you set CLIENT variable storage to a data source, you will find that the ColdFusion application server creates two tables called CDATA and CGLOBAL in the data source for this purpose. Cookies can be a good place to store CLIENT variable IDs, but all the limitations you have learned about cookies remain true in this case. There is one special advantage to CLIENT variables: Because they can be stored in a database, they can be used by multiple servers (perhaps in a cluster), since those servers can share the same database. As such, CLIENT variables are invaluable in the right situation. Creating CLIENT VariablesCLIENT variables are the only way to reliably store information about one user over multiple sessions. Although you can do this with cookies, the fact that COOKIE variables can be easily deleted or modified makes them less reliable. You create CLIENT variables using <cfset> and prefixing the variable name with CLIENT: <cfset CLIENT.FirstName="Emily"> You can also use <cfparam> to set default values for this variable. Using CLIENT VariablesTo use CLIENT variables, you just prefix them appropriately: <cfoutput>#CLIENT.FirstName#</cfoutput> The output of the preceding line will display the name Emily. |