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

Application variable help please!

Guest
Jun 22, 2009 Jun 22, 2009

Hello folks!

I am trying to use a application variable which is taking a input from a Login.cfm and passing to Auth.cfm . I am not able to use this application.WebPDMReports in Auth.cfm page and not sure what in heavens I am doing wrong please if you can look into my code.

Assuming WebPDMReports and USERID are defined in application.cfm.

Login.cfm

<cfparam name="WebPDMReports" default="">


  <cflock timeout=20 scope="Application" type="Exclusive">
     <cfset WebPDMReports="#cflogin.name#">

  </cflock>


<cflocation addtoken="no" url="../Auth.cfm">

Auth.cfm

<CFOUTPUT>

<CFLOCK SCOPE="session" TIMEOUT="30" TYPE="Exclusive">

  <CFSET session.USERID=#application.WebPDMReports#>  (If my session.USERID =loginuser then allows users to use index.cfm)
     
</CFLOCK>


</CFOUTPUT>

Please some one help me , I have wasted so much time just to make it work!!

TOPICS
Getting started
1.1K
Translate
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 ,
Jul 07, 2009 Jul 07, 2009

It looks like you need to amend:

<cfset WebPDMReports="#cflogin.name#">

to:

<cfset application.WebPDMReports="#cflogin.name#">

in the login.cfm file.

Translate
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
Engaged ,
Jul 07, 2009 Jul 07, 2009

When you think about variables in ColdFusion (or, really, any other language), you need to be mindful of namespaces and persistence.

Namespaces are the notion that there are several "dictionaries" (if you will...) in which a variable-name such as xyzzy might be considered to "reside."  In any given situation, some namespace is assumed if no explicit namespace-reference is given.  Local variables, global variables, session variables, field-names in a query ... all of these are distinct namespaces.  This is just a concept of the language that you need to be aware of ... you need to know that it exists, so when you see a name like xyzzy or plugh, you will understand how CF strictly interprets it.

(Otherwise, the black rod with the rusty star on the end might do unfortunate things, or the crystal bridge that spans the fissure might disappear while you are standing on it ...  And if you do not instantly understand what I am referring to, "foo! you are nothing but a charlatan!" )

Persistence is also an important consideration in HTML programming, since the entire HTML protocol is "stateless."  CF provides several built-in namespaces which have the characteristic of being "persistent," and each one is implemented in a different way.  All of them, however, rely upon some kind of token that must be passed between server and client and back again, subject to the realities of the HTTP and/or AJAX protocols.  You need to be aware of how this works so that there are no "holes in the water-barrier" (interesting what "bad words" are in Adobe's list...)  that you are not aware of.  CF is very good in providing a well-thought-out implementation that will conserve many of your hair-follicles but at some point, "HTTP is the protocol we use, and you must understand its implications."

Translate
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 Beginner ,
Jul 09, 2009 Jul 09, 2009
LATEST

It seems that you are not following the way which is needed to run the code successfully.

make sure following are done before proceeding.

1. application and server varaible option enabled on coldfusion server admin

2. Create application.cfm with below code

<cfapplication name = "TestApp" sessionManagement = "yes">

3. In the login.cfm use sample like below.

<cfset Application.WebPDMReports ="">

<cflock timeout=20 scope="Application" type="Exclusive">
<cfset Application.WebPDMReports="Test">

</cflock>

<cflocation addtoken="no" url="Auth.cfm">

4. In the auth.cfm page no modificatin needed.

Translate
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