On Mon, Aug 22, 2011 at 4:19 PM, Robert Harrison wrote:
> Please confirm... I only need that lock to hold long enough to set the 
> variable (in case multiple people are logging in at the same time) and DO NOT 
> need it for the entire session.
>
>                  <cflock scope="session" type="exclusive" timeout="20">
>                        <cfset session.userid="#getprofile.student_user_id#">
>                </cflock>

If multiple people sign in simultaneously they sign in to their own
individual session. So that is not a reason to lock at all.

The only reason to lock this code is if there is some other code that
would function incorrectly if the value of session.userid changed
while that code is running. In that case you have 2 options:
1. use an exclusive lock around all changes combined with a readonly
lock around the piece of code that requires the userid not to change;
2. copy the userid to a local variable before you enter the code that
requires the userid not to change and make that code use the local
variable instead of the session variable.

In my experience most web applications don't need programmatic locks
at all, they just need a proper definition of risks and ordering of
the operations.

Jochem


-- 
Jochem van Dieten
http://jochem.vandieten.net/

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346955
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to