added a missed reference and changed the order for cookie lookup