|
From: Nick201 on 15 Apr 2008 17:04 I am using session variable for my login. do i have to use cflock? I have only 20 users are using this app. I might use this app in the future for paying dues online. <cfif UCASE(Session.logged_in) eq "FALSE"> <cflocation url="test.cfm" addtoken="no"> </cfif> -------------------------------------------------------- Applcation.cfm <cfapplication name="app" sessionmanagement="Yes" clientmanagement="Yes" clientstorage="cookie" applicationtimeout="#createtimespan(2,0,0,0)#" sessiontimeout="#createtimespan(0,0,35,0)#"> <cfif isdefined("cookie.cfid") and isdefined("cookie.cftoken")> <cfset cfid_local = cookie.cfid> <cfset cftoken_local = cookie.cftoken> <cfcookie name="cfid" value="#cfid_local#"> <cfcookie name="cftoken" value="#cftoken_local#"> </cfif>
From: Ian Skinner on 15 Apr 2008 17:16 Nick201 wrote: > I am using session variable for my login. do i have to use cflock? Only if your code has a race condition with which you are concerned about. And with the session scope that would be fairly difficult because it would only exist if an individual user was using multiple browsers simultaneously connected to your application. OR you are using a very old version of ColdFusion! There is some VERY dated advice to ALWAYS use <cflock...> with all global scopes, including the session scope. This was from a bug in these scopes in the version 4.x days, with which locking all reads and writes to these scopes was a work around. That particular issue has not been relevant during the 21st century. But this 'best' practice does not seem to be going away. Even though it is no longer 'best' and in fact can cause serious performance and throughput issues creating an application that is not scalable if one is to over lock code unnecessarily.
From: Nick201 on 16 Apr 2008 09:28 So your advice is use cflock right.. where do i put cflock then. I mean in application.cfm page or everypage when i use session variable, Thanks
From: Ian Skinner on 16 Apr 2008 09:41 Nick201 wrote: > So your advice is use cflock right.. > > where do i put cflock then. I mean in application.cfm page or everypage when i use session variable, > > > > Thanks Ummm, No my advice is NOT to use <cflock....> unless you have a specific reason to do so. The only reason you would ALWAYS use <cflock...> is if you are still using ColdFusion 4.x? Are you still using a 10+ year old version of ColdFusion? If you do have a specific reason to use <cflock...> then you would put it around the specific piece(s) of code that you want only to be run one thread at at time not matter how many requests are trying to run it. Just be sure to understand the cost and limitations of doing so. You should understand the differences between named and scope locks and how they work with different <cflock...> blocks of code.
From: Nick201 on 16 Apr 2008 16:50
Thanks. Currently I am checking each single page -user log in or not <cfif (Session.logged_in) eq "FALSE"> <cflocation url="login.cfm" addtoken="no"> </cfif> Is this right? |