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!

Yet Another Client Management Q

Status
Not open for further replies.

ma701sd

IS-IT--Management
Dec 15, 2000
94
GB
Hi all,
Im using Client management but for some reason, the client variables does not seem to be deleted although the function
#getvariableList()# returns "Yes" ??

Basically, once a log out, I am pausing and looking to make sure the variables are being cleared. Once they have, I try to output the Variables (CFID and CFTOKEN) to check fr sanity that they have been.

This is causing me major aggro because when I try to log in as the same user, a New CFID is being assignend to that same user (But the same user should have the same CFID Surely??). I am storing the CFID and CFTOKEN values in a datastore.

Please help.. :-(


Heres the code for my logout page :


<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>

<html>
<head>
<title>Logout User</title>
</head>

<body>
<CFIF ISDEFINED ('Client.UserName')>

<CFOUTPUT>No of Client Variables before cleared = #GETCLIENTVARIABLESLIST()#</CFOUTPUT><BR><BR>
<CFSET DeletedUserName=DeleteClientVariable(&quot;Client.UserName&quot;)>
User Name Variable Delete Confirmed? <CFOUTPUT>#DeletedUserName#</cfoutput><BR>
<CFSET DeletedPassword=DeleteClientVariable(&quot;Client.Password&quot;)>
User Name Variable Delete Confirmed? <CFOUTPUT>#DeletedPassword#</cfoutput><BR>
<!--- <CFLOCATION URL=&quot;Index.cfm&quot; Addtoken=&quot;NO&quot;> --->
<CFCOOKIE NAME=&quot;cfid&quot; EXPIRES=&quot;now&quot;>
<CFCOOKIE NAME=&quot;cftoken&quot; EXPIRES=&quot;now&quot;>
<CFCOOKIE NAME=&quot;cfGlobals&quot; EXPIRES=&quot;now&quot;><BR>
<A href=&quot;Index.cfm?cfid=#cfid#&amp;cftoken=#cftoken#&quot;> Index </A><BR>
<CFELSE>
<CFOUTPUT>
#Client.UserName# was not passed to be deleted!
</CFOUTPUT>
</CFIF>

<CFOUTPUT>
<CFIF ISDEFINED ('Client.UserName')>
No of Client Variables after using delete client variable function =#GETCLIENTVARIABLESLIST()#
<BR>
#DeletedUserName#<BR>
#Deletedpassword#<BR>
</cfif>
</CFOUTPUT>
<BR>
<BR>


</body>
</html>
 
Hey Sam,

I wouldn't ever worry about the cfid &amp; cftokens as they are really for CF's use and I would let CF manage them. Just clear your username and password and that should effectively log the visitor out. If you set the cookies for cfid &amp; cftoken to expire, this will delete them from the browser and cause CF to assign new ones on the next page request. I don't think there's ever a reason why you would need to purge the cfid &amp; cftoken under normal circumstances.

It looks like your code should be deleting the username and password variables so is the problem that they are still showing up or is the problem just that new cfid &amp; cftokens are assigned? If it's the latter, I think removing the cfcookie statements will fix that.

Hope this helps,
GJ
 
Hi GJ,

I tried deleting the removing the CFCOOKIE statements, but it still seems to be assigning a new CFID for a user who already has a value for the CFID in the database?

What I'm also experiencing is that If i log out, and log in using the same user, initially I get an error saying the &quot;client.username&quot; is undefined,but If i click on refresh thrn it's OK. Why does it do that?

any ideas?

Sam

 
Hey Sam,

One thing to check is your delete statements. I don't know if this is the case across all versions but on my system you have to use DeleteClientVariable(&quot;UserName&quot;)> and not DeleteClientVariable(&quot;client.UserName&quot;)>. It doesn't delete the client variable if you prefix it with the client scope.

On the case of the cfid not matching, remember that the cfid/cftoken is tied to a browser and not a client variable. It doesn't matter what cfid they had before, if CF does not receive these from the browser via cookies or url variables, it will assign new ones every time. If your browser has cookies disabled, you will get new cfids every time. If you have set the &quot;no cookies&quot; option in your cfapplication tag, CF will again assign new ones if you don't pass them via url variables from every page. I would make a test page with the same <cfapplication> tag from your other pages and just output the cfid &amp; cftoken. You can then refresh this page several times to see if they change. If they do, then either your browser has cookies disabled or your cfapplication tag has setClientCookies set to &quot;no&quot;. If they don't change, you should then see these same values for cfid &amp; cftoken on the rest of your pages. If not, I would suspect the cfapplication tags are different somewhere.

As far as the error goes, it looks like you are attempting to access the client variable before it's been set but somewhere in your code, it gets set the second time through. I'd just have to see the code in question to see why that's happenning.

Hope this helps,
GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top