• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Sharing Application Variables

Explorer ,
Apr 22, 2008 Apr 22, 2008

Copy link to clipboard

Copied

I have an Application.cfm in the root of my site called App1. I have a directory in this site called Signup with an Application.cfm named App2, I would like App2 to check my Session.LoggedIn variable of the App1 application. Is this possible to do? If so how, i have been racking my brain on this for a few days. Thanks in advance!
TOPICS
Advanced techniques

Views

351

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 23, 2008 Apr 23, 2008

Copy link to clipboard

Copied

pflynn02 wrote:
> I have an Application.cfm in the root of my site called App1. I have a
> directory in this site called Signup with an Application.cfm named App2, I
> would like App2 to check my Session.LoggedIn variable of the App1 application.
> Is this possible to do? If so how, i have been racking my brain on this for a
> few days. Thanks in advance!
>

A template has access to the application scope defined by the name given
in the <cfapplication name="..."> tag or the this.name of a an
Application.cfc

A template can declare <cfapplicaiton ...> more then one time. So you
can do something like this in a specific template to combine the two
application scopes.

<cfapplication name="App1"...>

<cfset variables.localVariable1 = application.applicationOneVar>

...

<cfapplication name="App2"...>

<cfset variables.localVariable2 = application.applicationTwoVar>


<cfif variables.localVariable1 = variables.localVariable2>
<!--- Do stuff with the comparison --->
</cfif>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 23, 2008 Apr 23, 2008

Copy link to clipboard

Copied

Here is exactly what im trying to do, im not sure I understand your example...

App1 has a variable called : SESSION.MYACCOUNT

App2 needs to see if that SESSION.MYACCOUNT variable IsDefined BUT
when I tried to check it, it is looking in the App2 sessions not App1, how do I look in App1 for the SESSION.MYACCOUNT? Thanks...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 23, 2008 Apr 23, 2008

Copy link to clipboard

Copied

LATEST
App2 needs to see if that SESSION.MYACCOUNT variable IsDefined BUT when I tried to check it, it is looking in the App2 sessions not App1, how do I look in App1 for the SESSION.MYACCOUNT?

You can't. Sessions are privately owned by applications. App2 cannot read App1's session variables.

The following strategy will work. Assume the location of App1's Application.cfc file is wwwroot/app1/. Then add the 'extends' attribute to App2's Application.cfc file, as follows

<cfcomponent extends="app1.Application" ... etc>

App2 can now have access to App1's session variables. However, this is not a sweet structure, as it defeats the purpose of separate applications.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation