1 Reply Latest reply on Sep 12, 2011 3:58 PM by Dan Bracuk

    Question about components and session variables




      I'm having a problem accessing the correct session variables in a component and I'm just looking for some advice on any ways around it or how this is happening. Any help would be appreciated.


      In our application.cfc we are creating a component in the onRequestStart method like this:


      Request.Omniture = createObject("component", "controls.Omniture");



      Ok, so inside the Omniture component, there is a function called render that is called in our footer like this:




      This usually works fine. But for one of our new pages I need to access a variable that is created in the main component of the page that is called between these two. So I set a session variable thinking that everyone would have access to it and all would be well, and it almost is.


      The problem is that if I dump the session variables inside the main component and the render function of the omniture component, they will be different. Let's say the variable is NumRecords, then the first time the page is accessed, NumRecords will be set correctly in the session dump on the main part of the page, but it will be missing in the session dump in the footer. If I refresh the page, then everything will be OK. NumRecords will be set and the same on both dumps. If I submit a form that will cause NumRecords to change when the page refreshes, NumRecords will be changed in the main session dump but still be the old value in the footer session dump.


      So, this leads me to believe that when we do the createObject in the application.cfc, it is storing something that is causing this error. And then when the omniture render function is called, it is using some sort of stored version, but I'm not really sure. It's really baffling me.


      I'm am just starting to use coldfusion again after a few years and I haven't really used components before, so any help at all would be great.