1

What is the equivalent of this java statement in python?

post.setRequestHeader("Cookie", jSessionID);

I'm very confused as to whether this is really a cookie or just POST data with a key of 'Cookie'

I have urllib2 and cookielib imported, and am confused.

I'm also trying to send a file along with the url request, but that is another topic.

2 Answers 2

2

Try something like this:

sock = httplib.HTTPConnection('server.com', 80)
data = "op=a_login_attempt"
headers = { "Host":"server.com",
            "Content-Type":"application/x-www-form-urlencoded; charset=UTF=8",
            "Referer":"server2.com",
            "Cookie":"session=12345678",}
sock.request("POST", '/login.php', data, headers)

As you can see "Cookie" is just a key and value in the headers, which get sent along with the data using the request() method. Hope this answers your question.

Sign up to request clarification or add additional context in comments.

Comments

0

I would recommend pycurl

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.