lakshmananindia has asked for the wisdom of the Perl Monks concerning the following question:
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 LWPUsing WWW::Mechaniizeuse 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 +.
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?
The great pleasure in my life is doing what people say you cannot do.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DIfference between LWP and WWW::Mechanize
by jettero (Monsignor) on Apr 10, 2009 at 13:22 UTC | |
|
Re: DIfference between LWP and WWW::Mechanize
by Anonymous Monk on Apr 10, 2009 at 13:26 UTC | |
by targetsmart (Curate) on Apr 10, 2009 at 13:58 UTC | |
by Anonymous Monk on Apr 10, 2009 at 14:40 UTC | |
|
Re: DIfference between LWP and WWW::Mechanize
by nagalenoj (Friar) on Apr 10, 2009 at 13:58 UTC | |
by ikegami (Patriarch) on Apr 10, 2009 at 18:45 UTC | |
|
Re: DIfference between LWP and WWW::Mechanize
by isotope (Deacon) on Apr 10, 2009 at 16:35 UTC |