Velocity Reviews - Computer Hardware Reviews

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

Thread Tools

Cookies are not saved to cookie_jar

benny s.
Posts: n/a

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>

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

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

_____ tried that <br>
#create cookies jar to hold the cookies for this user agent<br>
my $cookie_jar = HTTP::Cookies->new( <br>
file =>
autosave => 1, <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
'delayload' => 0,<br>

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

$curUrl ="";<br>
print "getting $curUrl\n";<br>
@curContent = newGetRequest($curUrl);<br>

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

# get url to create a request from<br>
# Create a request<br>
$myReq = HTTP::Request->new(GET =>"$myUrl");<br>
#pass any cookies that exsists with this request <br>
# pass request to user agents<br>
$myRes = $ua->send_request($myReq); <br>
# if response put some cookies get them<br>
$cookie_jar->extract_cookies($myRes); # get cookies put by the
if ($myRes->is_success) {<br>
print "Success in GET $myUrl" ;<br>
return $myRes->content;<br>
{ <br>
print "Fail in GET $myUrl"; <br>
Reply With Quote

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