Maybe this will help. It's a sub from a Perl script I wrote that logs in
to a classic ASP web app. It snatches the cookie token to pass back with
subsequent requests after login.

#############################
#
#   subroutine: login
#               logs into XXXX and retrieves the login cookie.
#
#        takes: global data structure
#      returns: xml_writer obj
#
sub login {

        my $html_info = shift;
        addVerbose( "Logging into ecfmg website.\n" );

        my $success = 0;
        my $output = "";

        my $ua = LWP::UserAgent->new();
        $ua->agent('Mozilla/5.0');

        my $cookie_jar = HTTP::Cookies->new;

        # these settings are v. specific. Changes to the remote system
architecture must be
        #     reflected here.
        my $action = $html_info->{ 'login_action' };
        my $data = [
                                'txtUserName' => $html_info->{
'login_id' },
                                'txtPassword' => $html_info->{
'login_pwd' },
                                'txtMenu' => 'login.asp',
                                'txtPage' => 'login.asp'
                                ];

        my $res = $ua->request( POST( $action, Content => $data ) );

        # Check the outcome of the response
        if ( $res->is_error ) {
          my $msg = "Unable to login to remote system
$html_info->{login_action} using uid $html_info->{login_id} and password
$html_info->{login_pwd}.\n\n" . $res->status_line;
          addVerbose( $msg );
          send_error( $msg );
        }

        #       print $res->content;
        $cookie_jar->extract_cookies( $res );
        $cookie_jar->save( $html_info->{ 'cookie_fn' } );
        $html_info->{ 'cookie' } = $cookie_jar;

        return( $success );
}

----------------------------------------------
David R. Miller
Team Lead, Software Development
Medical Council of Canada
[EMAIL PROTECTED]
(613) 521-6012 x 2265
(613) 521-9722 (fax)
----------------------------------------------
This email may contain privileged and/or confidential 
information, and the Medical Council of Canada does 
not waive any related rights. Any distribution, use, 
copying or disclosure of this email or the information 
it contains by other than the intended recipient is 
strictly prohibited. If you received this email in error 
please delete it immediately from your system and notify 
the sender promptly by email that you have done so. The 
integrity and security of this message cannot be 
guaranteed on the Internet.  

Le présent courriel peut contenir de l'information 
privilégiée ou confidentielle. Le Conseil médical du 
Canada ne renonce pas aux droits qui s'y rapportent. 
Toute diffusion, utilisation ou copie de ce courriel 
ou des renseignements qu'il contient par une personne 
autre que le ou les destinataires désignés est interdite. 
Si vous recevez ce courriel par erreur, veuillez le 
supprimer immédiatement et envoyer sans délai à 
l'expéditeur un message électronique pour l'aviser que 
vous avez éliminé de votre ordinateur toute copie du 
courriel reçu. L'intégrité et la sécurité de ce message 
ne peuvent pas être garanties sur l'Internet

_______________________________________________
Perl-Win32-Web mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to