Question

How can I check whether Accept-Language header is present in request?
I've tried this, but it produces an error

<cfset requestData = GetHttpRequestData() >
<cfif IsDefined("requestData.Headers['Accept-Language']")>
...

Sorry for probably lame question. That's my first day of ColdFusion coding.

Was it helpful?

Solution

isDefined() is very limited in it's usage, so you can't use associative array notation with it. In almost every case you're better off using StructKeyExists() anyway. So, to solve your problem:

use: <cfif StructKeyExists( RequestData.Headers, "Accept-Language" )>

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top