我正在建立一个网站,我在其中遵循 MVC 来管理我的代码,而不使用任何框架。我已将所有查询放入 cfcs 并在我的 Application.cfm 中对其进行初始化,并将它们存储在如下应用程序变量中:
<cfset aplication.customerProfileObject=
createObject("component","cfc.customerprofile").init()>
为了执行任何查询操作,我创建了一个函数,然后像这样在任何地方调用它:
<cfset selectedCustomerOb =
application.customerProfileObject.getContactCustomerProfileDetail(session.userid)>
我不知道是什么导致了这个问题,但有时一个用户会访问另一个用户的数据。这怎么可能?它是在评估另一个用户的会话数据还是我初始化了 cfc 错误?
应用设置如下:
<cfapplication name="MyDataSourceName"
sessionmanagement="Yes"
setclientcookies="yes"
setdomaincookies="yes"
loginstorage="session"
sessiontimeout="#CreateTimeSpan(0, 2,0,0)#">
客户资料.cfc
<cfcomponent>
<cffunction name="init">
<cfreturn this>
</cffunction>
<cffunction name="getContactCustomerProfileDetail" returntype="query"
description="Returns customer contact details by contactid"
access="public">
<cfargument name="ccId" type="numeric" required="yes">
<cfquery name="getContactCustomerProfileDetail"
datasource="#Application.ds#"
dbtype="ODBC"
username="#Application.UserName#"
password="#Application.Password#">
<!-------My query here--->
</cfquery>
<cfreturn getContactCustomerProfileDetail>
</cffunction>
</cfcomponent>