def unset_cookie(self, name): """Remove a cookie from those that are being sent with the response""" cookies = self.headers.get("Set-Cookie") parser = BaseCookie() for cookie in cookies: parser.load(cookie) if name in parser.keys(): del self.headers["Set-Cookie"] for m in parser.values(): if m.key != name: self.headers.append(("Set-Cookie", m.OutputString()))
def unset_cookie(self, name): """Remove a cookie from those that are being sent with the response""" if PY3: name = isomorphic_decode(name) cookies = self.headers.get("Set-Cookie") parser = BaseCookie() for cookie in cookies: if PY3: # BaseCookie.load expects a text string. cookie = isomorphic_decode(cookie) parser.load(cookie) if name in parser.keys(): del self.headers["Set-Cookie"] for m in parser.values(): if m.key != name: self.headers.append(("Set-Cookie", m.OutputString()))