Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clearing Struct?

Status
Not open for further replies.

TamedTech

IS-IT--Management
May 3, 2005
998
GB
Hello Guys,

I've got a small issue i think, i've been buggering around with MX security over the last day or two, I'm using cfparam to set variables like application.dsn and application.cfcroot.

Problem being is it appears to be drawing the old variables when trying to load my pages as it thinks my cfc root is 'rob.components' even though in my application file its set to 'rob.com' using the cfparam.

I had it set to 'rob.components' this morning i'm guessing its drawing the old veriable from the struct.

How can i clear it so when i re-run application.cfc it will reset the variable?

Thanks,

Rob
 
remember that cfparam gets ignored if that variable already exists. also, it's best to not set application variables on every page request, application scope variables should only be set inside an exclusive lock which if done on every request will single-thread at least a portion of your site.

I would check for the existence of those variables, or another url paramater that you can pass to force re-initing the variables.
Code:
<cfparam name="reloadAppVars" default="false">
<cflock type="readonly" scope="application" timeout="10">
	<cfif (not isDefined("application.dsn") OR not IsDefined("application.cfcRoot")) OR isDefined("URL.init")>
		<cfset reloadAppVars = true>
	</cfif>
</cflock>

<cfif reloadAppVars>
	<cflock type="exclusive" scope="application" timeout="20">
		<cfset application.dsn = 'yourdsn'>
		<cfset application.comPath = 'yourcompath'>
	</cflock>
</cfif>

=========================================
Don't sweat the petty things and don't pet the sweaty things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top