fix errors when setting cookie