variables - Why a parameter is not defined, if I can dump it and it has a value in Coldfusion? -
just little clueless... using coldfusion8, if dump session file:
<cfdump output="d:\coldfusion8\logs\dump.txt" var="#session#">
this includes:
accounttyp: whatever
i same result if dump parameter:
<cfdump output="d:\coldfusion8\logs\dump.txt" var="#session.accounttyp#">
question:
if it's defined , dump-able, how come checking isdefined so:
<cfdump output="d:\coldfusion8\logs\dump.txt" var="#isdefined(session.accounttyp)#">
turns out no? if it's there should defined, shouldn't it?
thanks clarification.
<cfdump output="d:\coldfusion8\logs\dump.txt" var="#isdefined(session.accounttyp)#">
it because syntax incorrect. isdefined
expects name of variable ie string. omitting quotes around variable name, session variable gets evaluated first, , value ("whatever") gets passed isdefined
. code checking variable named "whatever", not "session.accounttyp" ie:
<cfif isdefined("whatever")>
that why result no
. correct syntax. (notice quotes , lack of pound signs).
<cfif isdefined("session.accounttyp")>
however, suggest switching structkeyexists
. preferred on isdefined
because more precise.
Comments
Post a Comment