Cookies are not saved to cookie_jar

Discussion in 'Perl Misc' started by benny s., Oct 27, 2003.

  1. benny s.

    benny s. Guest

    Hello,<p>

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

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

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

    any suggestions???<br>

    <br><br>
    use LWP::UserAgent;<br>
    use HTTP::Request::Common qw(POST);<br>
    use HTTP::Cookies;<br>
    use HTTP::Cookies::Microsoft;<br>
    <br><br>

    BEGIN { $LWP::DebugFile::eek:utname = 'c:/ua_debug.txt' }<br>
    use LWP::DebugFile qw(+); <br>
    <br><br>

    _____ tried that <br>
    #create cookies jar to hold the cookies for this user agent<br>
    my $cookie_jar = HTTP::Cookies->new( <br>
    file =>
    "c:/MyFolder/Cookies/lwp_cookies.dat",<br>
    autosave => 1, <br>

    );<br>
    <br>
    _____and also that<br>
    #create cookies jar to hold the cookies for this user agent<br>
    my $cookie_jar = HTTP::Cookies::Microsoft->new(<br>
    file => "c:/Documents and
    Settings/owner/Cookies/index.dat",<br>
    'delayload' => 0,<br>
    );<br>
    <br><br>

    my $ua; #user agent<br>
    $ua = LWP::UserAgent->new;<br>
    $ua->cookie_jar($cookie_jar);<br>
    <br><br>

    $curUrl ="http://www.mysite.com/Default.aspx";<br>
    print "getting $curUrl\n";<br>
    @curContent = newGetRequest($curUrl);<br>
    <br><br>

    sub newGetRequest() {<br>
    <br>
    my $myUrl;<br>
    my $myRes;<br>
    my $myReq;<br>

    # get url to create a request from<br>
    $myUrl=@_[0];<br>
    <br>
    # Create a request<br>
    $myReq = HTTP::Request->new(GET =>"$myUrl");<br>
    <br>
    #pass any cookies that exsists with this request <br>
    $cookie_jar->add_cookie_header($myReq);<br>
    <br>
    # pass request to user agents<br>
    $myRes = $ua->send_request($myReq); <br>
    <br>
    # if response put some cookies get them<br>
    $myRes->base("http://mysite.com/");<br>
    $cookie_jar->extract_cookies($myRes); # get cookies put by the
    site<br>
    <br>
    if ($myRes->is_success) {<br>
    print "Success in GET $myUrl" ;<br>
    return $myRes->content;<br>
    }else<br>
    { <br>
    print "Fail in GET $myUrl"; <br>
    }<br>
    <br>
    }<br>
    benny s., Oct 27, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Nitulescu

    Response.Cookies vs Request.Cookies

    Alex Nitulescu, Feb 3, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    8,454
    Hans Kesting
    Feb 3, 2005
  2. Andy Fish
    Replies:
    3
    Views:
    6,504
    Fredrik Lindner
    Nov 6, 2003
  3. user
    Replies:
    3
    Views:
    647
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Mar 31, 2007
  4. _Who
    Replies:
    7
    Views:
    2,630
  5. bigDWK

    HTTP::Cookies cookie_jar %rest hash

    bigDWK, Sep 29, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    175
    brian d foy
    Sep 29, 2004
Loading...

Share This Page