Note: This blog post is from 2008. Some content may be outdated--though not necessarily. Same with links and subsequent comments from myself or others. Corrections are welcome, in the comments. And I may revise the content as necessary.This may be a surprise to some: it was to me. I learned today for the first time that it's possible to find out (in code) for a given CFML app what client storage repository it's using:
Thanks go to Paul Kenney, as I found it in a page of his while I was doing a google search for some related info.
Why is this interesting?
I'm sure some may be wondering what the excitement is. Can't you easily tell what client storage repository a given app is using by looking at the ClientStorage attribute (of CFApplication when using application.cfm), or as a property in application.cfc? Sure.
But sometimes you may be left wondering how to view that value programmatically. Maybe you can't open those files (ok, that's a stretch), or maybe they include or invoke other application files, and trying to track those down is a hassle.
Also, one might not set the value in ClientStorage, in which case CF takes the default from the CF Admin, but a developer may not have access to the CF Admin, so can't know which repository they're really using.
How I found it, why I was looking
This came up when someone raised a problem on the Adobe Forums, where they said that several apps using a given clientstorage DSN worked, while one using it failed (all on the same server). I thought that odd, and wondered if the others may not really be using the DSN he thinks they are.
So I set off to find an answer. I hoped it might be in the servicefactory clientscopeservice, but it was not, in any of its available methods. While looking for possible examples of folks using that in ways I had not thought to, I found Paul's page above. What's nice about it is that it DOES NOT rely on the ServiceFactory, which of course is undocumented and unsupported (and can be disabled).
Some other thoughts about this getPersistSettings approach
This getPersistSettings approach above is just an undocumented method in the regular client scope: you won't see the value or this method being exposed in a simple dump of the client scope. But at least (unlike the servicefactory) it can't be disabled.
And I've tested it in CF7 and 8, and it worked fine.
Of course, if you're going to run this to help someone determine what storage they're using, you need to run it in the directory of whatever app you're trying to check. Be careful about mistakenly running it in some test directory outside of the app's directory.
And don't bother looking for other properties to "get". The only key in the structure that's returned by getPersistSettings is this one.
That said, it would be nice if it might also identify info about the client variable storage repository, such as how many days at which it's set to purge expired visitors, and whether "disable global variable updates" is enabled or not. You can get that info using the undocumented ClientScopeService in the ServiceFactory (just do some googling for info on it, and its available getclientstores method.) But it would be nice to have this info using the method above.
In fact, I've filed a feature request to get even this current clientstorage setting (and the info about the storage repository) available in a more direct and supported manner.
In the meantime, hope this may help some.
For more content like this:
Need more help with problems?
- Signup to get my blog posts by email:
- Follow my blog RSS feed
- View the rest of my blog posts
- View my blog posts on the Adobe CF portal
- If you may prefer direct help, rather than digging around here/elsewhere or via comments, I can help via my consulting services
- See that for more on how I can help a) over the web, safely and securely, b) usually very quickly, c) teaching you as we go, and d) with satisfaction guaranteed