We help IT Professionals succeed at work.

Testing for struct variables

I'm working with the Twitter API and am testing for the session variable (which exists) of SESSION.userdetails.accesspoint.  However, the cfinvoke is not being executed upon this condition.  Since I had a similar test not work until I simplified the structKeyExists, is this the correct way to test for this session variable?

<cfif structKeyExists(SESSION, 'userdetails.accesspoint') AND SESSION.userdetails.accesspoint EQ "Twitter">
Comment
Watch Question

Senior Analyst - Technology
CERTIFIED EXPERT
Commented:
Yes - structKeyExists is the best way to check for the existence of a structure key.

This is probably what you want...

<cfif structKeyExists(SESSION.userDetails, "accessPoint") AND SESSION.userDetails.accessPoint EQ "Twitter">

Author

Commented:
Thanks.  That is exactly what I needed.  I had not worked with complex structures and was not sure if I was writing that correctly.  When I set it that way, it worked as expected.  Thanks.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.