'Store (unique) cookies in the KB for later analysis.'

def _collect_cookies(self, request, response, cookie_object, cookie_header_value):

    cookie_keys = tuple(cookie_object.keys())
    uniq_id = (cookie_keys, response.get_url())
    if (uniq_id in self._already_reported_cookies):
        return
    self._already_reported_cookies.add(uniq_id)
    cstr = cookie_object.output(header='').strip()
    desc = 'The    URL:    "%s"    sent    the    cookie:    "%s".'
    desc = (desc % (response.get_url(), cstr))
    i = CookieInfo('Cookie', desc, response.id, self.get_name())
    i.set_url(response.get_url())
    i.set_cookie_object(cookie_object)
    '\n                                The    expiration    date    tells    the    browser    when    to    delete    the\n                                cookie.    If    no    expiration    date    is    provided,    the    cookie    is\n                                deleted    at    the    end    of    the    user    session,    that    is,    when    the\n                                user    quits    the    browser.    As    a    result,    specifying    an    expiration\n                                date    is    a    means    for    making    cookies    to    survive    across\n                                browser    sessions.    For    this    reason,    cookies    that    have    an\n                                expiration    date    are    called    persistent.\n                                '
    i['persistent'] = ('expires' in cookie_object)
    self.kb_append_uniq_group(self, 'cookies', i, group_klass=CollectedCookieInfoSet)
