|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Accessing Session and Application variables from another app
For reasons I won't go into, we have one directory in our main application which has it's own application scope. Is there any way for this sub-application to access session and application variables from the main app?Andy Matthews 08/18/08 05:19 P Couldn't you create a CFC in your main app that will return a value of aDave Phillips 08/18/08 05:24 P Sorry Andy, I didn't read your whole message. It appears you already triedDave Phillips 08/18/08 05:38 P You can use the CFAPPLICATION tag to temporarily change theBarney Boisvert 08/18/08 05:25 P Andy,Mark Kruger 08/18/08 05:29 P For reasons I won't go into, we have one directory in our main application which has it's own application scope. Is there any way for this sub-application to access session and application variables from the main app? Things that I've thought of: - A simple CF page which outputs the variables needed to the page. Then this page can be hit via HTTP request. Things I've tried - A CFC in the root which returns the variables requested I can't include, or reference the root app, so that option is out. Any other things that I can try? Couldn't you create a CFC in your main app that will return a value of a variable, something like this: <cffunction name="getVar"> <cfargument name="scope"> <cfargument name="varname"> <cfreturn "#arguments.scope#.#arguments.varname#" /> </cffunction> Expose the CFC to public and use <CFINVOKE> from your 'child' app. You could also access it with <cfhttp> if you would rather do that. Similar to your solution below, but more secure as it doesn't just dump all the variables - you have to know the name of it to get the value. You might want to add some error checking in case the varname or scope passed doesn't exist. In your 'child' app, you could set up a process that grabs those values and populates your application and session scope in the child app automatically on each request. Not pretty, but it should work. Dave For reasons I won't go into, we have one directory in our main application which has it's own application scope. Is there any way for this sub-application to access session and application variables from the main app? Things that I've thought of: - A simple CF page which outputs the variables needed to the page. Then this page can be hit via HTTP request. Things I've tried - A CFC in the root which returns the variables requested I can't include, or reference the root app, so that option is out. Any other things that I can try? Sorry Andy, I didn't read your whole message. It appears you already tried this. Couldn't you create a CFC in your main app that will return a value of a variable, something like this: <cffunction name="getVar"> <cfargument name="scope"> <cfargument name="varname"> <cfreturn "#arguments.scope#.#arguments.varname#" /> </cffunction> Expose the CFC to public and use <CFINVOKE> from your 'child' app. You could also access it with <cfhttp> if you would rather do that. Similar to your solution below, but more secure as it doesn't just dump all the variables - you have to know the name of it to get the value. You might want to add some error checking in case the varname or scope passed doesn't exist. In your 'child' app, you could set up a process that grabs those values and populates your application and session scope in the child app automatically on each request. Not pretty, but it should work. Dave You can use the CFAPPLICATION tag to temporarily change the application you're executing as part of. Highly hacky and rarely recommended, but it should work. cheers, barneyb ----- Excess quoted text cut - see Original Post for more ----- Andy, Sure...make sure "this.name" is the same in both apps.. ... But make sure they don't have different app scoped variables or one will overwrite the other. -mark Mark A. Kruger, CFG, MCSE (402) 408-3733 ext 105 www.cfwebtools.com www.coldfusionmuse.com www.necfug.com For reasons I won't go into, we have one directory in our main application which has it's own application scope. Is there any way for this sub-application to access session and application variables from the main app? Things that I've thought of: - A simple CF page which outputs the variables needed to the page. Then this page can be hit via HTTP request. Things I've tried - A CFC in the root which returns the variables requested I can't include, or reference the root app, so that option is out. Any other things that I can try?
|
May 24, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||