Hello,

I have got this script to automate submitting a form to a website and getting the response back.
only this site is powered by .net and when I use user agent to get even the home page it is allways getting an
error and redirecting to an error page asperrorpath=...

I found out the if I turn of the cookies I get this message all the time - meaning that the site is storing id
and session on my computer as a cookie.

so I added the cookie functionality to the user agent but I can't seem to have the site store the
cookies on any cookie folder not the cutom lwp_cookies (see script)
and not he default microsoft cookie folder.


any suggestions???

use LWP::UserAgent; use HTTP::Request::Common qw(POST); use HTTP::Cookies; use HTTP::Cookies::Microsoft; BEGIN { $LWP::DebugFile::outname = 'c:/ua_debug.txt' } use LWP::DebugFile qw(+);
_____ tried that
#create cookies jar to hold the cookies for this user agent my $cookie_jar = HTTP::Cookies->new( file => "c:/MyFolder/Cookies/lwp_c +ookies.dat", autosave => 1, );
_____and also that
#create cookies jar to hold the cookies for this user agent my $cookie_jar = HTTP::Cookies::Microsoft->new( file => "c:/Documents and Settings/owner/Cookie +s/index.dat", 'delayload' => 0, ); my $ua; #user agent $ua = LWP::UserAgent->new; $ua->cookie_jar($cookie_jar); $curUrl ="http://www.mysite.com/Default.aspx"; print "getting $curUrl\n"; @curContent = newGetRequest($curUrl); sub newGetRequest() { my $myUrl; my $myRes; my $myReq; # get url to create a request from $myUrl=@_[0]; # Create a request $myReq = HTTP::Request->new(GET =>"$myUrl"); #pass any cookies that exsists with this request $cookie_jar->add_cookie_header($myReq); # pass request to user agents $myRes = $ua->send_request($myReq); # if response put some cookies get them $myRes->base("http://mysite.com/"); $cookie_jar->extract_cookies($myRes); # get cookies put by the site if ($myRes->is_success) { print "Success in GET $myUrl" ; return $myRes->content; }else { print "Fail in GET $myUrl"; } }

Edit by thelenm: added code tags


In reply to Getting a Cookie from .net iis server by benny666

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.