W3C home > Mailing lists > Public > www-talk@w3.org > September to October 2002

Setting cookie and location in the same header

From: Swapna Samant <Swapna@ariba.com>
Date: Thu, 26 Sep 2002 11:43:58 -0700
Message-ID: <19A187F26DD4D311949F009027E28ACE0B2F6A90@us-mtvmail3.ariba.com>
To: "'www-talk@w3.org'" <www-talk@w3.org>


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

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

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:33:04 UTC