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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Client Variables in CFMX

Status
Not open for further replies.

GSXR179

Programmer
Oct 11, 2001
34
US
Hi does anyone know how to store and retrieve client variables in CFMX?

I get a error message the old way of doing things.

the error message is:

Element VLSUSER is undefined in CLIENT.

the code is:

<cfif NOT isDefined(&quot;user&quot;)>
<cfset user = #client.vlsuser#>
</cfif>

any suggestions?


Thanks in advance.

Mike
 
Ummm... you stated how you are retrieving the variable... but how are you setting it? Hope it helps,
-Carl
 
Thanks for your reply Carl.

Here is where we set the client variable.

<cftry>
<cftransaction>
<cfif isDefined(&quot;client.vlsuser&quot;) OR isDefined(&quot;Client.vlsAccess&quot;)>
<cfset DeleteClientVar = DeleteClientVariable(&quot;vlsAccess&quot;)>
<cfset DeleteClientVar = DeleteClientVariable(&quot;vlsUser&quot;)>
</cfif>
<cfset client.vlsuser = #vlsAdmin#>
<cfset &quot;client.vlsAccess&quot; = #USER_AUTHENTICATION.FK_SECURITY_CODE#>
</cftransaction>
<cfcatch>
<cfinclude template=&quot;../Exception/ClientVarError.cfm&quot;>
Error No client variable set
</cfcatch>
</cftry>

vlsadmin in this example is 4 the id number of the record.

Thanks again for the help, and any other suggestions.
 
While I had some questions about why you wrapped your client variable CFSETs in a CFTRANSACTION and whether a CFTRY would actually throw an exception if a client variable could not be set, I nonetheless duplicated your code on both my 5.0 and MX servers, like:

Code:
<html>
<cfapplication name=&quot;test&quot; clientmanagement=&quot;Yes&quot;>
<head>
	<title>Client Var Test</title>
</head>
<body>

<CFSET vlsAdmin = &quot;4&quot;>
<CFSET mySecurityCode = &quot;SecCode&quot;>

<cftry>
    <cftransaction>
        <cfif isDefined(&quot;client.vlsuser&quot;) OR isDefined(&quot;Client.vlsAccess&quot;)>
            <cfset DeleteClientVar = DeleteClientVariable(&quot;vlsAccess&quot;)>
            <cfset DeleteClientVar = DeleteClientVariable(&quot;vlsUser&quot;)>
        </cfif>
        <cfset client.vlsuser = vlsAdmin>
        <cfset client.vlsAccess = mySecurityCode>
    </cftransaction>
    <cfcatch>
        <cfinclude template=&quot;../Exception/ClientVarError.cfm&quot;>
        Error No client variable set
    </cfcatch>
</cftry>

<CFSET varList = GetClientVariablesList()>

<CFOUTPUT>

<p>Client var list:<br />&nbsp;&nbsp;&nbsp;#varList#</p

<p>My user:<br />&nbsp;&nbsp;&nbsp;#client.vlsuser#</p>

<p>My security code:<br />&nbsp;&nbsp;&nbsp;#client.vlsAccess#</p>

</CFOUTPUT>

</body>
</html>

and it works fine on both servers.

I'm thinking something is amiss in either your setting of the value of vlsAdmin, or the value of USER_AUTHENTICATION.FK_SECURITY_CODE. Have you tried outputting them right before you enter the CFTRY... just to make sure the values are as you intended?

And what happens when you do a
Code:
<CFDUMP var=&quot;#USER_AUTHENTICATION#&quot;>
?

Finally... does your MX server have a different default for client variable timeouts than your old CF server?
Hope it helps,
-Carl
 
Thanks again.

Yes I took your code and I ran it; and it did work.

So once these client variables get set I do a CFLOCATION to another page which gives the error :

Element VLSUSER is undefined in CLIENT as indicated in the first post.

So I'm back to square one.

Mike

 
Ahhhh... well that might be a completely different story.

As the docs for CFLOCATION state:
Code:
Warning
Code:
Do not set a cookie variable on a page on which you use the cflocation tag. If you do, the cookie is never saved on the browser. Likewise, if you use a cookie to store a client variable, the client variable is never set.

I believe that's been true since v4.5.

So how do you have your CFAPPLICATION set to manage client variables? If they're stored in a cookie, that might be your problem. Set it to store them in the registry instead.
Hope it helps,
-Carl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top