Minor fix with useless variable, and fix with cookie setting when exists