Refactored to use curl messages, also sending request cookies