Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old March 8th, 2001, 04:55 PM
walshs walshs is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 112 walshs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Talking

Hi

i am using LWP to grab a page which uses a cookie , i tried to use the cookie jar trick but for me it didnt work dont know why i even copied and pasted code of the net and even got some answers from a mailing list or 10 .

So i thought (yes i did) that why not grab the cookie info from the header and get perl to set the cookie for me so i did this by grabbing the Set-Cookie line and then priting it out as a Set cookie command.

However i need to change the domain to the the name of the site ie xyz.com for that cookie (apart from that cookie seems fine ) but i read somewhere that u cant do this with IE 4+ and NN 4 + is this true ?

ie the script which grabs the page is on ttt.com and the cookie domain is eee.com (just examples) i am using the code below it may nto be perfect but is a first attempt ,

any help ?

and remember i have tried the cookie_jar for 2 day non stop still wont work nothing worong with code dont know why

------------ 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 = "http://xxxxxxxxxxxxxx/cgibin/ca000001.pl?";

$url = $url . "PRODREF=23&RANDOM=$r&PATH=$path&PAGE=$page&SECTION_BLOB=$sec";



$ua = LWP::UserAgent->new();

$ua->agent("Mozilla/4.51 [en]");

#$ua->cookie_jar(HTTP::Cookies->new);

$request = POST 'http://xxxxxxxxxxxx/cgibin/ca000001.pl',[PRODREF=>'23',RANDOM=>$r,PATH=>$path,PAGE=>$page,SECTION_BLOB=>$sec];

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

$content=$ua->request($request)->as_string;

$act = "ACTION=\"http://xxxxxxxxxxxxxxxxx/cgi-bin/hd-new/next.pl?";

$content=~s/ACTION=\"/$act/g;

@arr = split(/\n/,$content);

foreach $key (@arr) {

if ($key=~m/Set/) {
$cart = $key;
}
}

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

$cc= "Set-Cookie: ACTINIC_CART=207Z173Z123Z198A984061318B13659C0; expires=Sat,08-Mar-2003 14:21:58 GMT; path=/; domain=hhh.com;";

print "$cc \n\n";
print $content;

------------------------------------------------------




the set cookie command (ie $cart) is similar to $cc

regards

Waseem
__________________
World Cup Football (Soccer) Forums
http://www.todayinsoccer.com

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Cookies - domain Prop


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

IBM developerWorks




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway