Fix minor bug in cookie detection