cj.set_cookie(cookielib.Cookie(0, 'a_cookie', 'a_value', '80', False,
    'domain', True, False, '/path', True, False, None, False, None, None, None)
    )
opener = urllib.request.build_opener(urllib.request.HTTPHandler(), cp)
opener.addheaders.append(('User-agent', 'Mozilla/5.0 (compatible)'))
opener.open('http://website.com').read()
Open web page with custom cookies in Python