Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Cookies are not saved to cookie_jar

Reply
Thread Tools

Cookies are not saved to cookie_jar

 
 
benny s.
Guest
Posts: n/a
 
      10-27-2003
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:ebugFile:utname = 'c:/ua_debug.txt' }<br>
use LWP:ebugFile 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>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Give Request.Cookies and Response.Cookies is there any reason to use another method to use cookies? _Who ASP .Net 7 09-18-2008 07:49 PM
1.Enter space bar for field names and save the field.The field shoud not get saved and an alert should be there as"Space bars are not allowed" Sound Javascript 2 09-28-2006 02:43 PM
Saved Mail Gone and Sent Mail Not Being Saved Gregg Firefox 6 03-06-2006 02:13 AM
Response.Cookies vs Request.Cookies Alex Nitulescu ASP .Net 1 02-03-2005 09:43 AM
HTTP::Cookies cookie_jar %rest hash bigDWK Perl Misc 1 09-29-2004 03:55 PM



Advertisments