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' => "password"]); 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 message. 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' => "passwd"]); 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.