Setting cookie and location in the same header

Hi,

I am trying to set the cookie and location in the same header but it does
not seem to work. Either I can get the cookie to set or the location, but
not both at the same time. My code is as follows.

    my $userAgent = new LWP::UserAgent();
    my $request = HTTP::Request::Common::POST($URL, $form);
    my $response = $userAgent->request($request);

        my $location = $response->header('Location');
        my $session = $response->header('Set-Cookie');
        $session =~ s/^JSESSIONID=//;
        $session =~ s/;.*//;
        my $cookie = $cgi->cookie(-name => "JSESSIONID",
                                                -value => $session);
#       -domain => "swapnas";

        print $cgi->header(-status => "302 Moved Temporarily",
                         	  -location => $location,
                        	  -cookie => $cookie);

This gives the following & the Set-Cookie header seems to get lost somewhere
in the picture. 

HTTP/1.1 302 Object Moved
Location: http://swapnas:8001/aw?awr=
Server: Microsoft-IIS/4.0
Content-Type: text/html
Content-Length: 155
 
<head><title>Document Moved</title></head>
                                          <body><h1>Object Moved</h1>This
docume

Thanks,
Swapna.

Received on Thursday, 26 September 2002 14:44:42 UTC