Fixing cookie handling for https/http by using curl.