How do you determine the current server's default and max session timeouts via code? This question came up on Twitter today and I thought I'd whip up a quick example. The answer is relatively simple - make use of the Admin API. Here's a quick example.
<cfset sessionDefaultTimeout = runtime.getScopeProperty("sessionScopeTimeout")>
<cfset sessionMaxTimeout = runtime.getScopeProperty("sessionScopeMaxTimeout")> <cfoutput>
The default timeout for sessions is #sessionDefaultTimeout# and the max value is #sessionMaxTimeout#.
</cfoutput>
<cfset admin = createObject("component", "CFIDE.adminapi.administrator")>
<cfset admin.login("admin")>
<cfset runtime = createObject("component", "CFIDE.adminapi.runtime")>
This results in (well, on my server anyway):
The default timeout for sessions is 0,0,20,0 and the max value is 2,0,0,0.
Those values are a string where the first number is days, the second is hours, the third is minutes, and the last is seconds. If you need to do math with the numbers, convert it to something real, like minutes:
<p/>
<cfoutput>
Total minutes for default sessionTimeout is #totalMinutes#.
</cfoutput>
<!--- convert to minutes --->
<cfset parts = listToArray(sessionDefaultTimeout)>
<!--- my total --->
<cfset totalMinutes = 0>
<!--- add in days --->
<cfset totalMinutes += 1440 * parts[1]>
<!--- add in hours --->
<cfset totalMinutes += 60 * parts[2]>
<!--- add in minutes --->
<cfset totalMinutes += parts[3]>
<!--- and seconds --->
<cfset totalMinutes += parts[4]/60>
This returns 20 on my server.
Archived Comments
I try to execute the code you provided and got
The current user is not authorized to invoke this method.
Any Ideas??
Peter, make sure you replace "admin" with your actual cfadmin password.
Thank you
Where are all these internal APIs defined. I would like to access one specifically that turns OFF caching if it is on.
This isn't an internal API. It's a documented feature. Go to /CFIDE/adminapi and you can see the CFCs there.
The official docs are here: http://help.adobe.com/en_US...
@cfaddict mentioned also application.getApplicationSettings() will return a struct w/ all of your application settings or new Application() - new instance.
And this is the link I used to see all the method documentation for the cfc's http://www.cfexecute.com/ad...
Hi Ray,
How do we implement the same for Railo?
Thanks
I don't use Railo.