POST+ASPX+COOKIE

TSZ <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
Pozdrawiam,
"Przeznaczenie - wymówka głupca w chwili klęski",
Wywrotowiec

Hello,

Is here anyone who could help beginner with checking some www site with 
authorization. It looks like this:

I connect to http://foobar.com -> open this page and find HIDDEN field 
with something like hash -> convert value from Hidden field to URL 
encoding -> POST 
http://foobar.com/Login.aspx?ValueFromHidenField&user=myuser&password=mypassword 
-> after that I should receive two cookies: sessionID and userID, but 
nothing like this happenes. I recived only one cookie -> then I should 
be able to get rest of the pages(after succesfull auth.).

use strict;
use LWP::UserAgent;
use HTTP::Cookies;
use CGI;

my $cj = HTTP::Cookies->new(
    file => 'f:\cooki.txt',
    autosave => 1,
  );
my $ua = LWP::UserAgent->new(cookie_jar=>$cj);
my $odp = $ua->post('http://foobar.com');
my $tekst = $odp->content;
my $mzz = index($tekst,'__VIEWSTATE'); #VIEWSTATE is this hidden field
my $mzz = index($tekst,"\"",($mzz+length('__VIEWSTATE')+1));
my $mzzz = index($tekst,"\"",($mzz+1));
my $vs = substr ($tekst,($mzz+1),($mzzz-$mzz-1));
my $vs = CGI::escape($vs);
my $odp = 
$ua->post('http://foobar.com/Login.aspx?ValueFromHidenField&user=myuser&password=mypassword');
print $odp->content;

Print prints content of http://foobar.com. I've tried to print 
$cj->extract_cookies( $odp ), but I've recived only HASH with adress.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.