def METHOD_NAME(self, doc):
    if web.ctx.get("_invalidation_inprogress"):
        # This event is triggered from invalidation. ignore it.
        return
    if any(doc.key.startswith(prefix) for prefix in self.prefixes):
        # The supplied does doesn't have the updated last_modified time.
        # Fetch the document afresh to get the correct last_modified time.
        doc = web.ctx.site.get(doc.key)
        t = doc.last_modified
        web.setcookie(self.cookie_name, t.isoformat(), expires=self.expire_time)