Neil,

> I am curious, I am setting up some session variables and have been doing
it
> via a cfparam at the mo to get a default var etc.. I have also been
locking
> it.   I have also been doing it via a cfscript call using StructInsert
which
> works just as well.  Should I lock the script block as well? or does it
> really matter either way?
>
> example.
>
> <cfscript>
> StructInsert(session,"homepage","view the homepage","YES");
> </cfscript>
>
> <cflock timeout="1" throwontimeout="No" name="detect" type="EXCLUSIVE">
> <cfparam name="session.homepage" type="string" default="EN">
> </cflock>
>

All reads and writes to shared scope variables MUST be locked.
Yes it does matter if you don't lock them!

To be honest, rather then doing cfparams inside a cflock I would do
something like this instead.....

<cfparam name="url.resetsession" default=TRUE type="boolean">
<cflock scope="SESSION" timeout="2" type="READONLY">
   <cfif NOT IsDefined("Session.homepage")>
     <cfset url.resetsession=TRUE>
   </cfif>
</cflock>

<CFIF url.resetsession>
   <cflock scope="SESSION" timeout="2" type="EXCLUSIVE">
      <cfscript>
         session.homepage = "whatever";
         etc.....
      </cfscript>
   </cflock>
</CFIF>

The idea is that you check one variable that is always present and then set
all the variables if that one is missing.  Where as if you use cfparam - you
are checking for the existance of every variable every time you hit the
application.cfm(?).

Hope this helps.

Stephen
______________________________________________________________________
Macromedia ColdFusion 5 Training from the Source
  Step by Step ColdFusion
  http://www.amazon.com/exec/obidos/ASIN/0201758474/houseoffusion

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to