Cookie issue

Rebased the cookie-issue branch so that tests pass again. #366 needs to be merged in order to maintain sessions between requests.