I have a coldfusion site with an application.cfm. It has a cfapplication defined in it:
<cfapplication name="FhaApp" clientmanagement="no"
sessionmanagement="yes" sessiontimeout="#createTimeSpan(0,0,360,0)#">
<cflock timeout="120" name="#session.sessionID#" type="exclusive">
<cfcookie name="CFID" value="#session.CFID#" >
<cfcookie name="CFTOKEN" value="#session.cftoken#" >
</cflock>
<cfparam name="session.fromwhere" default="">
<cfif #cgi.SCRIPT_NAME# contains 'default-partner-'>
<cfif not ISDEFINED("cookie.fromwhere")>
<cfcookie name="fromwhere" value="#right(cgi.SCRIPT_NAME, (len(cgi.SCRIPT_NAME)-1))#" expires="30">
<cfset session.fromwhere = #right(cgi.SCRIPT_NAME,(len(cgi.SCRIPT_NAME)-1))#>
</cfif>
</cfif>
<cfset datasourcename="fha47">
<cfparam name="application.dsn" default="fha47">
<cfparam name="session.loggedin" default="false">
<cfparam name="session.ppcid" default="101">
<cfparam name="session.cid" default="FHA">
I want to add another cfapplication that looks like this:
<cfapplication name = "QSvalues"
sessionTimeout = "#CreateTimeSpan(0,0, 0, 60)#"
sessionManagement = "yes">
<cflock scope = "Session"
timeout = "30" type = "Exclusive">
<cfif NOT IsDefined("session.prop_st")>
<cfset session.prop_st = "">
</cfif>
<cfif NOT IsDefined("session.prop_zip")>
<cfset session.prop_zip = "">
</cfif>
<cfif NOT IsDefined("session.address")>
<cfset session.address = "">
</cfif>
<cfif NOT IsDefined("session.email")>
<cfset session.email = "">
</cfif>
<cfif NOT IsDefined("session.fname")>
<cfset session.fname = "">
</cfif>
<cfif NOT IsDefined("session.lname")>
<cfset session.lname = "">
</cfif>
<cfif NOT IsDefined("session.pri_phone_1")>
<cfset session.pri_phone_1 = "">
</cfif>
<cfif NOT IsDefined("session.pri_phone_2")>
<cfset session.pri_phone_2 = "">
</cfif>
<cfif NOT IsDefined("session.pri_phone_3")>
<cfset session.pri_phone_3 = "">
</cfif>
</cflock>
<cflock scope = "Application" timeout = "30" type = "Exclusive">
<cfif NOT IsDefined("application.number")>
<cfset application.number = 0>
</cfif>
</cflock>
My question is, can you define two separate cfapplication in the main application.cfm?
I’m not entirely sure why you would want or need the second cfapplication; it’s not really clear from your code or explanation. I think you could probably put another one in there, but it would likely override the previous one.
Besides, in your code all you’re doing is writing to the application scope.. that’s not really declaring another cfapplication.
A couple of tips though… your big cfif area for the session values, just use cfparam:
That way if it doesn’t already exist, it will be created.
Also, if you’re using the latest ColdFusion, you don’t need to cflock around session scopes. You should be locking around the application scope settings, but since you’re setting them in Application.cfm, it’s kinda silly.. I would use another scope, like the request scope.
On your cfif cgi.script_name, you don’t need # signs around that variable. The only times you need them are when they’re quoted or are being outputted in a cfoutput (or when used with Evaluate() to create dynamic variables).
I hope this helps.