|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Cookies - domain Prop |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|