Using getURL and a header map variable to login and browse an external website

Using getURL and a header map variable to login and browse an external website

How can I send a Session cookie to an external webpage?

I'm trying this which doesn't work?

string getstayzdata.LoginAndBrowse()
{
    mymap=map();
    mymap.put("Cookie","PHPSESSID=7351b12k6001ovsqo8dunvj0q6");
    buff = getUrl("http://server.address.com/",mymap);
    return buff;
}

The return page indicates that the server did not receive the Cookie in the request headers.

What I'm actually trying to do is 

  1. log in to a website with a getURL call (which is working fine - I'm getting response text from the page reached after successfully logging in).
  2. Read the Response Headers to find the  PHPSESSID cookie value.
  3. Add the   PHPSESSID cookie  to the Request Headers (as per above) in subsequent getURL calls
so I can obtain data from an external website as if I was browsing pages after logging in. The site just authenticates with the    PHPSESSID.

Please help - it's driving me mad and holding up a much bigger project!

Larry