Modified cookies validation, and added origin header validation