8 Replies Latest reply on Feb 5, 2009 10:57 AM by Newsgroup_User

    Session timeouts

    JimLoving
      We have an application that has an "onRequestStart" method in the application.cfc. In there, we identify a request after a session times out and present the login screen back to the user. Unfortunately, we have users that start entering data, get side-tracked and then finish entering, only to have the data trashed when they submit and the session has timed out. I have tried doing a <cfdump> on the "Form" structure and specific field names only to have ColdFusion tell me the structure is emtpy or the variable is not defined. Obviously, the form data is being sent back to the server by the browser, but disappears along the way. Is there any way to capture the submitted data? It would be nice to write hidden fields on the "re-login" page and then resume what the user was doing upon reauthentication.
        • 1. Re: Session timeouts
          Level 7
          Where *exactly* are you trying to dump the form variable?

          Can you describe the application flow when the orRequestStart detects an
          session timeout?

          • 2. Re: Session timeouts
            JimLoving Level 1
            Here's chunks of the code:
            <cffunction name="onRequestStart">
            <cflogin>
            ... after login, create currentUser object and store on session
            </cflogin>
            <cfif Not isDefined("session.currentUser")>
            <cfif not isDefined("Form.j_username") >
            <cfset timeOut = true /> ... used to display timeout code...
            <cfinclude template="headNoBanner.cfm" />
            <cfinclude template="dspLogin.cfm" />
            <cfdump var="#ColdFusion#">
            <cfinclude template="foot.cfm" />
            <cfreturn false />
            </cfif>
            ... assign other session variables
            </cfif>
            </cffunction>

            I've tried the dump where shown, at the beginning of onRequestStart and on the dspLogin.cfm page, all with same results: nothing!

            Do you know if there are any coldfusion.runtime. java objects availble with the form variables?
            • 3. Re: Session timeouts
              Level 7
              JimLoving wrote:
              >
              > I've tried the dump where shown, at the beginning of onRequestStart and on the
              > dspLogin.cfm page, all with same results: nothing!
              >
              > Do you know if there are any coldfusion.runtime. java objects availble with
              > the form variables?
              >

              What is #ColdFusion#. That is not a default variable scope, it would
              have to be something built by your code.

              I would expect you to be dumping the form scope. I.E. <cfdump
              var="#form#">; or the URL scope if your form happens to use the get
              method instead of the post method.




              • 4. Re: Session timeouts
                JimLoving Level 1
                Sorry, the #ColdFusion# was an error. when I cut and pasted, I was in the process and entering a string into the Java runtime and trying to dump a list of java objects.

                I have tried #Form#, and even #Description# where 'Description' is the name of one of the <input> fields on the form. When I used #Form# I got an empty structure and when I used #Description# I got variable not defined. I'm trying to find something, such as GetPagecontext().getVariableScope() that provides what is in the form, but without success. Any syggestions on these runtime methods?

                Sorry for the confusion.
                • 5. Re: Session timeouts
                  Level 7
                  JimLoving wrote:
                  >
                  > Sorry for the confusion.
                  >

                  Ok. that does clarify things. I have no idea where a form structure
                  would be buried inside of the Java underpinnings of ColdFusion, but I
                  don't think you need to go there just yet.

                  What you are trying to do should be working as expected. That tells me
                  your application is doing something unexpected. The trick with the form
                  and url scopes is that they *only* exist in the request that sent them.
                  If your server does anything to jump to another request they will be
                  thrown away.

                  That is why the first thing I looked for when you provided the code was
                  a <cflocation...> a common way of redirecting users to a login page.
                  That would have definitely lost any form data sent to the original request.
                  • 6. Re: Session timeouts
                    JimLoving Level 1
                    The overall flow is that the user comletes a form on their browser and clicks submit. Unfortunately, their session has expired, so the original request is never completed. I'm trying to capture their work in the "onRequestStart" method in application.cfc. It is my understanding that ColdFusion executes onRequestStart first before it does anything else, so the Form data should be there, but it is not. Is there some other order of events on the server after a user clicks submit?
                    • 7. Re: Session timeouts
                      Level 7
                      Well, I just had a couple of minutes and I gave this a try.

                      I am surprised, but it does look like the form scope is not available to
                      the onRequestStart method.

                      That really surprises me.

                      Ian
                      • 8. Re: Session timeouts
                        Level 7
                        Ian Skinner wrote:
                        > I am surprised, but it does look like the form scope is not available to
                        > the onRequestStart method.

                        Let me reverse that!!!!

                        Stupid me, I did not have a name for my form field so the browser was
                        not posting anything... DUH!

                        This works as I would expect it.

                        Application.cfc
                        ---------------
                        <cfcomponent output="no">
                        <cfscript>
                        this.name = "NewApplicationA";
                        </cfscript>

                        <cffunction
                        name="onRequestStart"
                        output="yes"
                        returntype="boolean">

                        <cfargument
                        name="targetPage"
                        required="yes"
                        type="string">

                        <cfdump var="#form#">

                        <cfreturn true>
                        </cffunction>
                        </cfcomponent>

                        simpleCFML.cfm
                        --------------
                        <cfoutput>
                        #dateFormat(now(),'dd mmmm yyyy')#<br/>
                        #timeFormat(now(),'HH:mm:ss:l')#

                        <form action="simpleCFML.cfm" method="post">
                        <input name="George" type="hidden" value="FOOBAR" />
                        <input type="submit" />
                        </form>

                        <cfdump var="#form#">
                        </cfoutput>