avi_2009 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Guys: I have written a perl script which queries a REST web service. My problem is script logs in and out pretty fine but after i login, i try to fire queries. For each query, i got this result back - <ns2:status xmlns:ns2="urn:status" xmlns:ns3="urn:path">sessionExpired</ns2:status> My user agent code -
# Create a user agent object $ua = LWP::UserAgent->new; $cache = $ua->conn_cache(LWP::ConnCache->new( )); $ua->conn_cache->total_capacity(undef); $ua->agent("MyApp/1.3");
I thought cache is going to solve the problem but it didn't. Any suggestions? Thanks in advance --Avi

Replies are listed 'Best First'.
Re: HTTP session Problem
by Fletch (Bishop) on Feb 24, 2009 at 15:02 UTC

    The sessions are most likely implemented by some sort of cookie so you need to give your agent instance a cookie jar (see HTTP::Cookies and friends) or use WWW::Mechanize which handles that kind of thing for you.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      Hi Fletch: That was awesome. Thank you so much. I just made the following change. I hope this is going to help others in future -
      $mech = WWW::Mechanize->new( agent => 'wonderbot 1.01' );
      And used $mech to POST and GET URLs! --Avi