我正在构建一个网站,我跟随MVC来管理我的代码而不使用任何框架。我已经把我所有的内部氟氯化碳的查询和正在初始化他们我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)#">
CustomerProfile.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>
如果'session.userid'是空白怎么办?您的CFC是否会返回第一个(也可能是全部)'customerprofile'记录? – beercodebeer
你有Skyhook的代码吗?getContactCustomerProfileDetail()' –
听起来像在CFC中没有适当的范围。 – ale