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!

Existence of a variable

Status
Not open for further replies.

sanek

Programmer
Jun 9, 2005
6
RU
How can I check whether a variable exists or not. I tried the isDefined but that doesn't seem to work. I'm using it for checking of a session variable.

Thanks,
Alex
 
Hey Alex,

This is the syntax.

<cfif isdefined(&quot;session.var1&quot;)>
... Code here...
</cfif>

A common mistake is to use the variable instead of the variable name like this.
<cfif isdefined(#session.var1#)>
This passes the variable object instead of the variable name and will give an error.

Let me know if you still have problems.
GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top