Handle cookies not being written correctly at times