title: logging into https site using python mechanize library
body: <p>I have the following code:</p>
  
  <pre><code>import requests
  import sys
  import urllib2
  import re
  import mechanize
  import cookielib
  #import json
  #import imp
  #print(imp.find_module("requests"))
  #print(requests.__file__)
  EMAIL = "******"
  PASSWORD = "*******"
  
  URL = 'https://www.imleagues.com/Login.aspx'
  address = "http://www.imleagues.com/School/Team/Home.aspx?Team=27d6c31187314397b00293fb0cfbc79a"
  br = mechanize.Browser()
  cj = cookielib.LWPCookieJar()
  br.set_cookiejar(cj)
  br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
  
  br.add_password(URL, EMAIL, PASSWORD)
  br.open(URL)
  
  #br.open(URL)
  #br.select_form(name="aspnetForm")
  #br.form["ctl00$ContentPlaceHolder1$inUserName"] = EMAIL
  #br.form["ctl00$ContentPlaceHolder1$inPassword"] = PASSWORD
  #response = br.submit()
  #br= mechanize.Browser()
  site = br.open(address)
  
      # Start a session so we can have persistant cookies
  #session = requests.Session()
  
      # This is the form data that the page sends when logging in
  #login_data = {
   #   'ctl00$ContentPlaceHolder1$inUserName': EMAIL,
   #   'ctl00$ContentPlaceHolder1$inPassword': PASSWORD,
    #  'aspnetFrom': 'http://www.imleagues.com/Members/Home.aspx',
  #}
  #URL_post = 'http://www.imleagues.com/Members/Home.aspx'
      # Authenticate
  #r = session.post(URL, data=login_data)
  
      # Try accessing a page that requires you to be logged in
  #r = session.get('http://www.imleagues.com/School/Team/Home.aspx?Team=27d6c31187314397b00293fb0cfbc79a')
  
  
  
  website = site.read()
  
  
  f = open('crypt.txt', 'wb')
  f.write(website)
  
  #print(website_html)
  </code></pre>
  
  <p>I am trying to log into this site to monitor game times and make sure they aren't changed on me (again).  I've tried various ways to do this, most commented out above, but all of them redirect me back to the login page.  Any ideas?  Thanks.</p>