Current location: Hot Scripts Forums » Programming Languages » Perl » Can't seem to get the cookies to the cookie_jar


Can't seem to get the cookies to the cookie_jar

Reply
  #1 (permalink)  
Old 10-26-03, 08:58 PM
benny666 benny666 is offline
New Member
 
Join Date: Oct 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Can't seem to get the cookies to the cookie_jar

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:ebugFile:utname = 'c:/ua_debug.txt' }
use LWP:ebugFile 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_cookies.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/Cookies/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";
}

}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 10-28-03, 05:54 AM
outsource_india outsource_india is offline
Newbie Coder
 
Join Date: Oct 2003
Location: chennai , tamil nadu , India
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
perl lwp cookies jar

try an "ALL LOWER CASE WITHOUT SPACES" file path for both of these..


c:/MyFolder/Cookies/lwp_cookies.dat

and

c:/Documents and Settings/owner/Cookies/index.dat
__________________
Chris, Director, Chrisranjana.com
Asp web php developers
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form cookies kelas JavaScript 1 07-04-03 01:42 PM
how to get my sessions script work with cookies JM007 PHP 1 06-24-03 09:06 AM
problem in cookies @ phppro list vb2vb PHP 13 06-22-03 09:04 PM


All times are GMT -5. The time now is 07:29 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.