Porting a recent cookie fix to remove empty cookies when they are set