Python Forum

Full Version: Save Cookie header value in var
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I need to get the value of a cookie which is 'JSESSIONID_AV'
I should save the value of this cookie for re-use in the rest of my orders in my API
I would like to know how I can do everything while keeping the code below

from urllib2 import Request, urlopen
import ssl, os
if (not os.environ.get('PYTHONHTTPSVERIFY', '') and
    getattr(ssl, '_create_unverified_context', None)): 
    ssl._create_default_https_context = ssl._create_unverified_context

values = """
  {
    "email": "********",
    "password": "********"
  }
"""

headers = {
  'Content-Type': 'application/json'
}
request = Request('https://200.2.1.20:7443/api/2.0/login', data=values, headers=headers)

response_body = urlopen(request).read()


print response_body.headers
thank you