Correctly handle invalid cookies