To check if it exists, use StructKeyExists:
StructKeyExists(Cookie,Form.cookie_name)
To use the variable, use bracket notation:
Cookie[Form.cookie_name]
Don't forget both Form variables and Cookie variables are submitted by the user/client - and thus must be treated appropriately (i.e. never trust that they contain what you think they do, because it's not guaranteed).
Note, if you did want to use the
isDefined form to do this (though there's benefit to it), it would need to be written like so:
isDefined("Cookie['#Form.cookie_name#']")
Which would then be evaluated as Cookie['606ac80d']
- without those single quotes it would be an invalid variable.
As noted by Leigh, the above works in Railo and OpenBD, but not in Adobe ColdFusion, where you would need to write:
isDefined("Cookie.#Form.cookie_name#")
This syntax will work for simple alphanumeric variable names, but specifically may cause issues if form.cookie_name contained a value with a .
in.