HTTPConnection Sending Cookies to server

Lamonte Harris pyth0nc0d3r at gmail.com
Mon Dec 15 07:56:05 CET 2008


Right now I can login to www.phpbb.com's forums

import httplib, urllib
params =
urllib.urlencode({'username':'TheInfernoSin','password':'PASSWORD','login':1,'sid':'','redirect':'index.php','autologin':1})
headers = {"Content-type": "application/x-www-form-urlencoded","Accept":
"text/plain"}
con = httplib.HTTPConnection(url)
con.request("POST","/community/ucp.php?mode=login",params,headers)
data = con.getresponse()
#print data.read()
hdrs = data.getheader('set-cookie')
header = {"Cookie": hdrs}
print header
#print hdrs

con2 = httplib.HTTPConnection(url)
#con2.request("GET","/community/ucp.php",None,header)
con2.connect()
con2.putrequest("POST","/community/ucp.php")
con2.putheader("Cookie",hdrs)
con2.endheaders()
data = con2.getresponse()
print data.read()

The first block of code logins in and if printed it'll show the logged in
successful html code, but when trying to go to another page and sending that
cookie back to the server, it wont allow me to stay logged in.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081215/604cea21/attachment.html>


More information about the Python-list mailing list