I've currently got an OpenBD application where I'm trying add a
feature request where the user can set their preferred session timeout
time. The top of my application.cfc looks like:

------
<cfcomponent name="Application" displayname="My App" output="false" >
        <cfset this.name = "MyApp">
        <cfset this.applicationTimeout = CreateTimeSpan(0,2,0,0)>
        <cfset this.sessionManagement = "true">
        <cfset this.sessionTimeout = CreateTimeSpan(0,0,20,0) />
        <cfset this.clientManagement = "false">
        <cfset this.scriptProtect = "false">
=======


I'm also using the OnRequest method so that I have access to the
application.cfc variables from my index.cfm page, which is acting like
a poor-man's controller in this setup.

------
        <cffunction name="onRequest" returntype="boolean" output="true">
                <cfargument name="targetPage" required="true">

                <cfinclude template="#ARGUMENTS.TargetPage#" />

                <cfreturn true>
        </cffunction>
======

I have a cfm page that includes a form where the user can set the
desired number of minutes they'd like their session to last.

------
<div>Account Timeout (minutes)</div>
<input type="timeout" name="user_timeout" value="#(this.getTimeout() *
24 * 60)#" maxlength="3" />
======

When the form is submitted the onRequest function is run, which
includes the corresponding bit of index.cfm code:

------
<cfset this.sessionTimeout = createTimeSpan(0,0,form.user_timeout,0) /
>
======

Displaying or logging the "this.sessionTimeout" variable after this
point shows that the session amount has been successfully changed.
However, as soon as I move to another page (make another request)
logging the "this.sessionTimeout" shows that it is now reset to the
default, or 20 minutes. I briefly thought that it might be because the
this.sessionTimeout is getting set every request at the top of the
application.cfc file. However, changing the the psuedo constructor at
the top of Application.cfc to:

------
<cfcomponent name="Application" displayname="My App" output="false" >
        <cfset this.name = "MyApp">
        <cfset this.applicationTimeout = CreateTimeSpan(0,2,0,0)>
        <cfset this.sessionManagement = "true">
        <cfif StructKeyExists(this,"sessionTimeout") and this.sessionTimeout
neq createTimeSpan(0,0,20,0)>
                <cflog text="timeout exists - #this.sessionTimeout#. leaving
alone.">
        <cfelse>
                <cflog text="timeout reset" />
                <cfset this.sessionTimeout = CreateTimeSpan(0,0,20,0) />
        </cfif>
        <cfset this.clientManagement = "false">
        <cfset this.scriptProtect = "false">
======

Why am I unable to change the sessionTimeout? How is the variable
continuing to get reset? Is there a better way of doing this?

- Matthew

-- 
Open BlueDragon Public Mailing List
 http://www.openbluedragon.org/   http://twitter.com/OpenBlueDragon
 official manual: http://www.openbluedragon.org/manual/
 Ready2Run CFML http://www.openbluedragon.org/openbdjam/

 mailing list - http://groups.google.com/group/openbd?hl=en

Reply via email to