application.cfc in subdir not getting session variables from application.cfm in the parent directory

StackOverflow https://stackoverflow.com/questions/13313654

  •  28-11-2021
  •  | 
  •  

Question

I have an application.cfc in folder /wwwRoot/beta/. They have an application.cfm in the root which sets bunch of session variables. When I hit one of the pages in the beta folder to dump all the session vars, I don't see the ones that were defined in the application.cfm.

I modified my application.cfc to get rid of all the code within 'onSessionStart'. That didn't help. I created a new application.cfm with a few application varibales I needed. That didn't help either.

Does anybody have any suggestions?

   <cffunction name="onSessionStart" returnType="void" output="false" hint="Fires ONLY ONCE when session first created and not when session renewed/restarted.">
    <cfscript>
        session.startTime = Now();

    </cfscript>
    <cfreturn>
</cffunction>

I guess I will need to some how copy existing session vars.

I created a simple test page on the above folder.

<cfset session.mynum= 1111>
 <a href="beta/index.cfm">clicky</a>

When I click on the link, the session dump does not include myNum. Something in application.cfc is screwing things around.

Was it helpful?

Solution 2

Found the problem! In the application.cfc I have the following at the top:

 <cfscript>
   this.name = "myApp";
 </cfscipt>

the name of the application must be as same as the one that is being used in the tag in application.cfm. Once the name was changed, I was able to get the session vars.

thanks

OTHER TIPS

Application.cfc will not be affected by an Application.cfm in the parent folder. You should replace the Application.cfm with an Application.cfc and then in your child folder you should extend the parent Application.cfc. This is the way the Application framework in ColdFusion functions.

That said, if you cannot replace the Application.cfm with an Application.cfc then you could break out the session variable definition into a separate file and then cfinclude it into the Application.cfm and repeat that inclusion in the Application.cfc in the child folder. However, you may have other things in your Application.cfm that will also not be included in the Application.cfc in the child folder so this isn't really a great solution. The best solution is to get rid of the Application.cfm altogether, replace it with a proper Application.cfc in the root and then extend that from any child folders as necessary.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top