develooper Front page | perl.libwww | Postings from March 2001

LWP and Cookies

Thread Next
Waseem Aslam
March 7, 2001 12:14
LWP and Cookies
Message ID:

I am writing a perl script to track tranactions using
a specific shopping cart, the problem is i using
LWP::UserAgent to grab the pages and then grab the
value of the cart before payment (this is a simple
text processign thing) 

But if i use the normal site without (LWP) a cookie is
set, for the shopping cart. But when i use LWP to goto
the same page as the code shows below, no cookie is
set thus no items enter the shopping cart . 

Thus i am using the HTTP:Cookies module thingy but all
i get in the $cookie_jar is "#LWP-Cookies-1.0". 

If you can help cool, or if you know of any good
forums for perl which give quick responses e-mail and
i mean QUCIK  

Code ---- 

!/usr/local/bin/perl -w 

print "Content-type: text/html\n\n"; 

use CGI qw(:standard escapeHTML); 
use LWP::Simple; 
use HTTP::Request::Common qw(POST); 
use HTTP::Request::Common qw(GET); 
use LWP::UserAgent; 
use HTTP::Cookies; 

$pr = param('PRODREF'); 
$r = param('RANDOM'); 
$path =param('PATH'); 
$page = param('PAGE'); 
$sec = param('SECTION_BLOB'); 
$ref = param('REFPAGE'); 
$pq = param('PREVQUERY'); 

$url = ""; 

$cookie_file = "/whoaskedyou/cookies.txt"; 

# Set up the User Agent 

$ua = LWP::UserAgent->new(); 
$ua->agent("Mozilla/4.51 [en]"); 

# Set up the Cookie Jar 

$cookie_jar = HTTP::Cookies->new( file =>
$cookie_file, ,ignore_discard => 1); 

# Set up the Request 
$url = $url .

$request = HTTP::Request->new(GET => $url); 

# Pass our cookie(s) to the server 


# Set up the Response 

$response = $ua->request($request); 

# Extract the Set-cookie headers from the server


# Save the cookie jar's state 

print $cookie_jar->as_string() ; 

#printf ("\nHere is the state of your cookie

print $response->as_string(); 


Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About