For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > November 2007 > keeping http session between requests









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author keeping http session between requests
zawszedamian_p@gazeta.pl

2007-11-29, 7:08 pm

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
Ben Morrow

2007-11-29, 7:08 pm


Quoth zawszedamian_p@gazeta.pl:
> I was trying to download page and keep http session between requests
> like this:
>

<snip>
>
> 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

Sherman Pendley

2007-11-29, 7:08 pm

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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com