Before reading this FAQ, I suggest that if you're new to CFLOCK and/or sessions that you read up on them.
CFLOCK in a simple explanation to suit this FAQ sets cold fusion (a language engine that generally handles multiple threads) to a single thread type until the locked process is done or times out. If you use the name attribute of CFLOCK, well then it single threads in a queue all cflocks with that name.. IE 30 different locks may be in your application and if 5 have the same name, then if 2 or more lock instances with the same namese 5 are accessed simultaneously CF handles them on a first come, first serve basis.. But other processes with different lock names can be accessed at the same time. This is to help keep your application running smoothly without corrupting itself.
I was presented with an application that has about 500 calls to session variables in it, and none of them were locked, it was going to be my job to lock every read on a session variable.. But I found that session variables are stored in the memory and client variables (application,cookie,request) are stored on a page by page basis in a basic definition.. so I could, in application.cfm code the following:
By doing it this way, I could call it as suser from anywhere in the application, even custom tags.. by calling #caller.suser#.
Because this was then set as a page variable.. I didn't need to lock and could use it, read from, write to it freely.. I was able to return to the client a fast application with only minutes of work invested, rather than hours as it would have taken by manually putting in every cflock.