Partially wrote cookie logic