Dear Gisle,

Sorry for not following the issue sooner. I was on vacation for the last
couple of weeks.

As I said in my previous and immediate reply, your script, as is, DID
generate entries in the "cookie jar" file.

However, just changing the site's address to "http://www.magna.isa.gov.il";,
without changing anything else, not even a single character, generates the
old symptom - no entries in the cookie-jar file and thus no sending of a
cookie on any of the subsequent "GET" requests.

(BTW, The Firefox browser does handle right cookies with this internet
site.)

What's wrong with this site?

Regards
Meir 


-----Original Message-----
From: Meir Guttman [mailto:m...@guttman.co.il] 
Sent: Sunday, May 23, 2010 10:29 PM
To: 'Gisle Aas'
Subject: RE: Cookies not saved to a file (thus no sent)

Hello Gisle!

Thanks for your prompt help.

Yes, it does work for me too! So tomorrow I'll try to copy your example to
my situation.

Thanks!
Meir
Ashdod, Israel

BTW, my understanding is that you are from Norway, isn't it? Last year we
took a nature cruse through the Svalbard islands. It is one of my top ten,
no less. And I was in many places all over the world, so believe me, I can
compare. Please keep it unspoiled for the rest of us... 

M.G.

-----Original Message-----
From: gisle....@gmail.com [mailto:gisle....@gmail.com] On Behalf Of Gisle
Aas
Sent: Sunday, May 23, 2010 9:55 PM
To: Meir Guttman
Subject: Re: Cookies not saved to a file (thus no sent)

The following example:

  use LWP::UserAgent;
  use HTTP::Cookies;
  my $jar = HTTP::Cookies->new(file => "lwp.jar", autosave => 1);
  my $ua = LWP::UserAgent->new(cookie_jar => $jar);
  $ua->get("http://www.google.com";)->dump;

fills the 'lwp.jar' file with a few entries for me.  Doesn't it do so
for you too?

--Gisle


On Sun, May 23, 2010 at 18:54, Meir Guttman <m...@guttman.co.il> wrote:
> Dear LWP wizads!
>
>
>
> I began my usage of cookies support in LWP (libwww-perl ver. 5.836) under
> Perl, (v5.10.1 for MSWin32-x86-multi-thread) as follows without the
> commented-out code:
>
>
>
>
>  use LWP::UserAgent;
>
>  use HTTP::Cookies;
>
>
>
>  ...
>
>
>
>  my $browser = LWP::UserAgent->new();
>
>
>
>  my $cookies_file = 'LWP_Cookies.lwp';
>
>  my $cookie_jar = HTTP::Cookies->new({file => $cookies_file, autosave =>
> 1});
>
>  # $cookie_jar->load($cookies_file);
>
>  $browser->cookie_jar($cookie_jar);
>
>  # $cookie_jar->add_cookie_header($browser);
>
>
>
>  #  ... some browsing code, including:
>
>  my $response = $browser->get($url_canonical);
>
>
>
>  # $cookie_jar->extract_cookies($response);
>
>  # $cookie_jar->save($cookies_file);
>
>
>
> The result was that the file 'LWP_Cookies.lwp' was created but empty,
> despite the HTTP server issuing a "Set-Cookie: xyz" header line. The file
> contains just the following text:
>
>
>
>  #LWP-Cookies-1.0[\n]
>
>  [eof]
>
>
>
> (The square brackets signify new-line and end-of-file, respectively, not
> literal text.)
>
>
>
> Obviously, since the file is empty, on repeat GET requests from that site
no
> cookies were sent as part of the GET HTTP header.
>
>
>
> Question #1: Should the minimal code above be enough to save received
> cookies and to retrieve and send cookies?
>
>
>
> I then added the above commented out calls to the
> $cookie_jar->load($cookies_file) and $cookie_jar->save($cookies_file)
> methods with no discernable change.
>
>
>
> Question #2: aren't these methods superfluous here?
>
>
>
> I then added the $cookie_jar->extract_cookies($response); statement right
> before the cookie jar save statement. This didn't change anything either.
> The 'LWP_Cookies.lwp' file was still created empty!
>
>
>
> I also tried to add $cookie_jar->add_cookie_header($browser) to the
request
> preparation. That in turn caused an error message "Can't locate object
> method "uri" via package "LWP::UserAgent" at
> C:/Perl/site/lib/HTTP/Cookies.pm line 42."
>
>
>
> Question #3: What is wrong with the invocation of this cookie_jar method?
>
>
>
> And generally, what do I do wrong?

Reply via email to