All,
I posted yesterday regarding having session timeout issues before the 2hr limit
we have setup. This is completely random. One of the suggestions I got was to
make sure I'm using CFLOCK where appropriate. So after reading tons about
CFLOCK, I'm still confused as to how it applies to session scoped components.
Here is how I'm using CFCs:
I create the user object in the session scope:
<!---CREATE THE USER OBJECT --->
<cfobject name="session.myUser" component="/cfc/myUser">
<cfset session.myUser.init(#form.userid#)>
All variables in the component are scoped at the VARIABLES level, inside the
CFC. Any time that I need to get or set information inside the CFC I use
getter/setter functions or I do so inside the CFC:
<!---GET THE USERID--->
<cffunction name="getUserID" output="false" returntype="string" access="remote">
<cfreturn variables.userID>
</cffunction>
The call from a page in the site would look something like:
<cfset variables.currentUserID = session.myUser.getUserID()>
OR
<cfset session.myUser.setUserID(#form.userid#)>
NOTE: There is NO <cflock> around any of these functions (as shown above).
The first function would obviously return data that is in the variables scope
inside the CFC.....which is in session, but not a direct "session.varname"
reference which as I understand, does in fact need a <cflock> wrapped around
it.
Hopefully you can see my confusion. At this point I am not using <cflock> for
any of my function calls to the "myUser" component in session. Do I need to do
so? Technically, my understanding is that the "session.myUser" object is a
complex data type variable that is in session. So any time I write/read data
from this object (even if the data is inside it in the variables scope) do I
need a CFLOCK around it? Such as:
<cflock scope="Session" type="Exclusive" timeout="2" throwontimeout="Yes">
<cfset variables.currentUserID = session.myUser.getUserID()>
</cflock>
OR
<cflock scope="Session" type="Exclusive" timeout="2" throwontimeout="Yes">
<cfset session.myUser.setUserID(#form.userid#)>
</cflock>
The book I have here in front of me (Programming ColdFusion MX, 2nd ED from
o'reilly) has a section in chapter 22 called "Assigning Component Instances to
Shared Variable Scopes".....it does not mention anything about using cflock for
this stuff.
I honestly can't confirm or deny if cflock has anything to do with our issues.
I'm leaning towards it not being relevant because the problem is that the
"session.myUser" object is completely gone....not corrupted by a race condition
but not existing at all when using an isdefined('session.myUser').
Any help is greatly, greatly appreciated. We are trying to get to the bottom
of a big problem that has our customers very unhappy (at least the ones that
are timing out).
thanks in advance!
jason
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Macromedia ColdFusion MX7
Upgrade to MX7 & experience time-saving features, more productivity.
http://www.adobe.com/products/coldfusion?sdid=RVJW
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:274678
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4