I have some code that is using mechanize and a password protected site. I can login just fine and get the results I expect. However, once I log in I don't want to "click" links I want to iterate through a list of URLs. Unfortunately each .open() call simply gets a re-direct to the login page, which is the behaviour I would expect if I had logged out or tried to login with a different browser. This leads me to believe it is cookie handling of some sort but I'm at a loss.
def main():
browser = mechanize.Browser()
browser.set_handle_robots(False)
# The below code works perfectly
page_stats = login_to_BOE(browser)
print page_stats
# This code ALWAYS gets the login page again NOT the desired
# behaviour of getting the new URL. This is the behaviour I would
# expect if I had logged out of our site.
for page in PAGES:
print '%s%s' % (SITE, page)
page = browser.open('%s%s' % (SITE, page))
page_stats = get_page_statistics(page.get_data())
print page_stats