Skip to main content
July 15, 2008
Question

scope of a current function

  • July 15, 2008
  • 1 reply
  • 545 views
My cold fusioon 8.0 website defines alot of functions using the CFFUNCTION tag, however because of limitations within cold fusion, I cannot call these functions as application or session scope variables because the server will only allow one instance of the function running at once. Instead, I created all of my functions and store them as application scope variables and during each page visit,I define request scope variables off of the application scope variables, and then call the function defined under the request scope.

For security reasons, I am required to ensure that the application scope version of the CFFUNCTION cannot be called from anywhere within the website. Is there a way to build such a check into a CFFUNCTION to determine what scope it is currently running under so that I can deny anyone who tries to call the application scope version of each function.
This topic has been closed for replies.

1 reply

Inspiring
July 15, 2008
Your first paragraph does not make any sense. If the server will only allow one instance of the function to run at once, then nothing you have done so far helps you solve that problem.

Are you saying that you can't do this?
<cfinvoke returnvariable = "session.something">?

If so, why not do this?
<cfinvoke returnvariable = "somevar">?
<cfset session.something = somevar>
July 15, 2008
My understanding is that session and application scope UDFs act in the same manner, so I stay away from declaring my function in either one of those scopes. The Application scope for an obvious reason, only one web visitor at a time could call the function. The session scope because I had some functions which are called within themselves, which causes a deadlock. I decided to go with declaring application scope UDFs and copying them to the request scope, as such...

1) I created a bunch of UDFs and declared them under the application scope, such as this...

<cfif not isdefined("application.myFunction")>
<cffunction name="myFunction" returntype="boolean" output="false">
:
<cfreturn true>
</cffunction>
<cflock scope="application" timeout="10"><cfset application.myFunction=myFunction></cfif>
</cfif>

2) Then in the application.cfm I declared a request scope of the application scope UDF, which is what I used to call the UDFs.
:
<cfset request.myFunction=application.myFunction>
:

Some of the application scope UDFs are only copied to the request score if the current user has a certain level of access. I wanted a way to ensure that even if someone found a way to execute an application scope UDF, that it would not perform the action. This is why I was asking if anyone knew of a way of determining the current scope of a running function.