code: def set_cookie_if_ok(self, cookie, request):
          
          self._cookies_lock.acquire()
          try:
              self._policy._now = self._now = int(time.time())
  
              if self._policy.set_ok(cookie, request):
                  self.set_cookie(cookie)
  
  
          finally:
              self._cookies_lock.release()
docs: Set a cookie if policy says it's OK to do so.