Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error due to CFsession.logged.

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi There:

I am getting an error while logging in

it says
"Symbol session.logged is in a scope that contains data shared across threads and cannot be accessed without an active lock"

my login.cfm code is given below

------------
<cfparam name=&quot;action&quot; default=&quot;&quot;>
<html>
<head><title>Login</title></head>
<body>
<cfif action is &quot;login&quot;>
<cfquery name=&quot;checklogin&quot; datasource=&quot;intervox&quot;>
select * from user
where login='#login#' and password='#password#'
</cfquery>

<cfif checklogin.recordcount>
<cfset session.logged=1>
<cfset session.login=form.login>

<cfquery name=&quot;username&quot; datasource=&quot;intervox&quot;>
select * from user where login like '#session.login#'
</cfquery>

<cfquery name=&quot;logdel&quot; datasource=&quot;intervox&quot;>
Insert into logtable
(user,action,when)
values
('#username.firstname#','Logged In',#now()#)
</cfquery>
<cflocation url=&quot;mainpage.cfm&quot; addtoken=&quot;yes&quot;>
<cfelse>
We do not have a member with the information you provided.<br>
Please try again.
</cfif>
</cfif>
<cfoutput>
<form action=&quot;login.cfm?cfid=#cfid#&amp;cftoken=#cftoken#&quot; method=&quot;post&quot;>
</cfoutput>
<p align=&quot;center&quot;> <img src=&quot;ivx1.jpg&quot;>
<p align=&quot;center&quot;><b>Information System for Intervox Officials.</b>

<table align=&quot;center&quot; bgcolor=&quot;#990033&quot; cellspacing=&quot;2&quot; cellpadding=&quot;2&quot; border=&quot;0&quot;>
<tr>
<TD>
<P><FONT face=Arial><FONT
color=#ffff00><STRONG>Login</STRONG></FONT>:<INPUT maxLength=6 name=Login
size=7>&amp;nbsp;&amp;nbsp;<FONT
color=#ffff00><STRONG>Password</STRONG>&amp;nbsp;</FONT></FONT>&amp;nbsp;<INPUT
maxLength=6 name=Password size=7 type=password></P>
&amp;nbsp;&amp;nbsp;&amp;nbsp<INPUT type=submit value=&quot;Login Now&quot;>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;<INPUT type=reset value=Reset></TD>
</tr><input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;login&quot;>
</table></P></FORM>


</body>
</html>
-----------------------

Please help me solve it at the earliest.

Thanx
GG
 
I believe this is what you need. The session variables are in a shared scope which needs locking to avoid stability problems. You can use a read only lock when you're just getting the values but you'll need an exclusive lock when writing to the variables. The exclusive locks are more resource intensive on the server so it's best to use them only on the writes.

GJ

<cflock scope=&quot;Session&quot; type=&quot;exclusive&quot; timeout=&quot;5&quot;>
<cfset session.logged=1>
<cfset session.login=form.login>
</cflock>
 
Try your code again with <CFLOCK> tags around the piece of code where you set your session variables:

<cfif checklogin.recordcount>

<cflock name=&quot;SessionData&quot; timeout=30>


<cfset session.logged=1>
<cfset session.login=form.login>

</cflock>

et cetera


As a general rule in CF, you should use CFLOCK to do updates / settings of variables in the application, server and session scopes. Locking the variable protects it from being corrupted by another process while you are working with it.
A name, plus a timeout (in seconds) is required.

Hope this helps...
<webguru>iqof188</webguru>
 
Sorry GunJack, I was typing my advice while you posted your reply. :). Anyway, we share the same opinion about the problem, good! ;-) <webguru>iqof188</webguru>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top