Skip to main content
April 15, 2008
Question

session variable

  • April 15, 2008
  • 2 replies
  • 531 views
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>
This topic has been closed for replies.

2 replies

12Robots
Participating Frequently
April 17, 2008
<cfif (Session.logged_in) eq "FALSE" AND cgi.script_name NEQ "login.cfm">
<cflocation url="login.cfm" addtoken="no">
</cfif>
Inspiring
April 15, 2008
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.

April 16, 2008
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