keeping http session between requests
am 29.11.2007 20:19:47 von zawszedamian_p
I was trying to download page and keep http session between requests
like this:
my $request = HTTP::Request->new(GET => $URL_login_page);
my $response = $browser->request($request);
# save cookie
$cookie = $response->header("Set-cookie"); # here cookie is not null
$request = HTTP::Request->new(GET => $URL_get_data);
# set saved cookie
$request->header("Set-cookie", $cookie);
but it does not work - session is not not forwarded to second request,
cookie's gone
how can I keep session between requests?
thanks for your help
Re: keeping http session between requests
am 29.11.2007 21:23:11 von Ben Morrow
Quoth zawszedamian_p@gazeta.pl:
> I was trying to download page and keep http session between requests
> like this:
>
>
> but it does not work - session is not not forwarded to second request,
> cookie's gone
>
> how can I keep session between requests?
Use the cookie_jar option the LWP::UserAgent->new.
Ben
Re: keeping http session between requests
am 29.11.2007 21:47:05 von Sherm Pendley
zawszedamian_p@gazeta.pl writes:
> I was trying to download page and keep http session between requests
> like this:
>
> my $request = HTTP::Request->new(GET => $URL_login_page);
> my $response = $browser->request($request);
> # save cookie
> $cookie = $response->header("Set-cookie"); # here cookie is not null
>
> $request = HTTP::Request->new(GET => $URL_get_data);
> # set saved cookie
> $request->header("Set-cookie", $cookie);
>
> but it does not work - session is not not forwarded to second request,
> cookie's gone
>
> how can I keep session between requests?
You might want to have a look at WWW::Mechanize.
sherm--
--
WV News, Blogging, and Discussion: http://wv-www.com
Cocoa programming in Perl: http://camelbones.sourceforge.net