reordering the function checks to squash a bug with an empty cookie
reordering the function checks to squash a bug with an empty cookie

fhferreira/Detector,cynhard/Detector,dmolsen/Detector,dmolsen/Detector,hamway/Detector,fhferreira/Detector,dmolsen/Detector,hamway/Detector,cynhard/Detector,dmolsen/Detector,hamway/Detector,mimmi20/Detector,fhferreira/Detector,cynhard/Detector,mimmi20/Detector