House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Accessing Session and Application variables from another app

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Andy Matthews
08/18/2008 05:19 PM

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?

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dave Phillips
08/18/2008 05:24 PM

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?

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dave Phillips
08/18/2008 05:38 PM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Barney Boisvert
08/18/2008 05:25 PM

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 -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Mark Kruger
08/18/2008 05:29 PM

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?


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 24, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31     

Designer, Developer and mobile workflow conference