Hai monks, Greets.

I just want to know, what difference it will make when I post using LWP and WWW::Mechanize. Below is what I experimented, which triggers this question.

Using LWP
use strict; use warnings; use LWP::UserAgent; use Data::Dumper; my $url = "http://192.168.1.5/src/Login_validate.php"; my $mech = LWP::UserAgent->new(); my $response=$mech->post($url,[ 'name' => "username", 'passwd' => "pas +sword"]); if(!$response->is_success()) { print "Failiure\n"; } print Dumper \$mech->get("http://192.168.1.5/src/allbooks.php"); __DATA__ In allbooks.php I checked if(isset($_SESSION['id']) and if not I print "Session expired" error m +essage. So when I executed the above code, it prints "Session expired" message +.
Using WWW::Mechaniize
use strict; use warnings; use WWW::Mechanize; use Data::Dumper; my $url = "http://192.168.1.5/src/Login_validate.php"; my $mech = WWW::Mechanize->new(); my $response=$mech->post($url,[ 'name' => "username", 'passwd' => "pas +swd"]); if(!$response->is_success()) { print "Failiure\n"; } print Dumper \$mech->get("http://192.168.1.5/src/allbooks.php"); __END__ The above code print the html contents, echoed by allbooks.php and I'm + not getting the session expired message.

So can any one please explain why LWP and WWW::Mechanize works differently in my case?

--Lakshmanan G.

The great pleasure in my life is doing what people say you cannot do.



In reply to DIfference between LWP and WWW::Mechanize by lakshmananindia

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.