Вы должны использовать LWPCookieJar
import urllib, urllib2, cookielib
url='http://localhost:8080/rest/auth/latest/session'
post={"username" : "admin", "password" : "hunter2"}
post_data=urllib.urlencode(post)
cookie = cookielib.LWPCookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie))
opener.open(url,post_data)
cookie.save('cookie_filename', True)