use request library instead of http/https

request has a pretty good cookie implmentation.