br = mechanize.Browser()
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)
ck = cookielib.Cookie(version=0, name='Name', value='1', port=None,
    port_specified=False, domain='www.example.com', domain_specified=False,
    domain_initial_dot=False, path='/', path_specified=True, secure=False,
    expires=None, discard=True, comment=None, comment_url=None, rest={
    'HttpOnly': None}, rfc2109=False)
cj.set_cookie(ck)
for index, cookie in enumerate(cj):
    pass
How to add cookie to existing cookielib CookieJar instance in Python?