Here is the code that I got working which successfully uses the cookie
from the first request in order to POST a login to the second request.

        use HTTP::Cookies;
        use HTTP::Request;
        use LWP::UserAgent;

        # First HTTP request to mainpage (get initial cookie)

        my $ua1 = LWP::UserAgent->new(keep_alive => 1);
           $ua1->agent('Mozilla/5.0');
        my $req = new HTTP::Request 'GET','http://www.intervalworld.com/web/cs';
        my $cookie_jar = HTTP::Cookies->new;
           $ua1->cookie_jar($cookie_jar);

        my $res = $ua1->request($req);

        print $res->as_string;

        # Now for my second request that requires the above cookie for login

        $req = new HTTP::Request 
'POST','https://secure.intervalworld.com/web/cs';
        $req->content_type('application/x-www-form-urlencoded');
        $req->content('a=5&loginID=XXX&loginPassword=XXX&rememberMe=y');
        $req->referrer('http://www.intervalworld.com/web/cs?a=5');
        $res = $ua1->request($req);

        print $res->as_string;


Cookie works as expected here. Could just have been how I was using it in
earlier attemps. Since I re-use $ua1 (which contains the valid cookie
objects for the session) I can continue to hit pages internal to the site
which require authentication.


Reply via email to