Actually, rereading your code with fresh eyes, I understand what you're trying to do now. You don't need a callback to read a cookie, you can just use
$xf.request.getCookieRaw('cookieKey'). Since you don't need
<xf:callback>, you can store the unescaped value using the alternate
<xf:set> syntax:
HTML:
<xf:set var="$cookieKey" value="{{ $xf.request.getCookieRaw('cookieKey') }}" />
You should then be able to use
$cookieKey in conditionals like you expect. Apologies for the confusion, though I would still caution against placing this sort of logic directly in templates (even if it is technically possible). It works in a pinch but would likely fall outside of the
resource standards for add-ons.