Sharing application scope
This question has been asked in the past but not answered completely, so here is my issue:
I am currently working on a site that has two separate sections(one public section and another admin section), but need to share the same Application variables.
Basic file structure....
Root
-- Admin -- Application.cfc -- index.cfm
-- Application.cfc -- index.cfm
The public side will contain the application start and end code and the the admin Application.cfc will include the public application.cfc(<cfinclude template="../Application.cfc" />) and the login logic. The reason I am trying to do this is that my application scope needs to be accessible by both sides. My understanding is that the CF server will treat this all as one application since they have the same name.
During my testing, I set application.cfcroot variable in the public application.cfc. That variable is not accessible in the admin subfolder. My understanding is the fact that by including the original(public) application.cfc, the application.cfcroot variable will be accessible in subfolders(in this case: admin). Th error I get is that the variable is undefined. I test this by trying to dump the application right after I include it in my application.cfc located in the admin folder. For example:
Contents of application.cfc in root:
-------------------------------------------
<cfset this.name="myapp" >
<cffunction name = "onApplicationStart">
<cfset application.cfcroot = "myapp.cfcs.">
</cffunction>
-------------------------------------------
Contents of application.cfc in admin folder:
-------------------------------------------
<cfinclude template="../Application.cfc" />
<cfdump var="#application#" label="1" />
-------------------------------------------
error:
Variable APPLICATION is undefined.
Any ideas?
