Why Client Variables are Flawed
posted under category: ColdFusion on July 7, 2005 at 1:00 am by Nathan
Client variables in ColdFusion are flawed. Inherently from the start, they're no good to use. First off, where are you going to store the data?
Registry: Don't do this. Especially if you intend on having users on your web site. This expands your registry and will make your whole server slow.
Cookie: Don't do this (see 6.3). Limitations in browser cookies keep you from storing large amounts of data. Maxing out browser cookies can have (very!) unforeseen consequences. This also will increase your network traffic and bandwidth.
Database: Don't do this. Constant updates and heavy traffic will kill your database (and thus cf) servers. Come on people, there are better ways of storing data in the database.
A couple other annoyances and pet peeves of mine are:
- All options are server-wide, it would be cool to have different options for each application
- For my database's sake, select the data once and only insert/update them at the end of the session
- Need more storage options, how about using files or a proprietary client variable server (aka state server)
I think there's still something to be said for dynamically created persistent data that can be tied to unknown visitors. Too often we use a cheap cookie (watch those limits), or go overboard and change our database schema to add a temporary property, but a better structure from the start would solve that.
What we need is a more intelligent client scope that will fix the insanity. We need more control over the little things, even over the inserts and updates in the database. It's got to be built with open source CFCs or expose itself with extendable java. Mix it with CFMX 7's new Application.cfc event handlers (especially onSessionEnd) and we could have something really useful.
There are only a couple ways of going about getting what we want. We either build it ourselves or we beg the CF developers and hope for the best. My money is on doing it myself. I'll be thinking more about this, so expect to see more posts about it in the future.