Fix problem with recording cookie writes for certain cases