Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Need same named cookies

by gregor-e (Beadle)
on May 16, 2003 at 22:16 UTC ( [id://258777]=perlquestion: print w/replies, xml ) Need Help??

gregor-e has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to use WWW::Mechanize to navigate through a site and ultimately download a report each day. After I get within one screen of where I need to go, the HTML contains JavaScript that sets 4 cookies and uses an onclick button handler to jump to the screen I need. The problem I'm running into is that the 4 cookies repeat the same name twice, like:
<script language="JavaScript" type="text/javascript"> // Set cookies document.cookie = "Report_Profile_ID=654321;path=/cgi-bin\"; document.cookie = "Report_Profile_ID=654321;path=/actuate"; document.cookie = "FirstTime=1;path=/cgi-bin"; document.cookie = "FirstTime=1;path=/actuate"; // end cookie set </script>
I tried to fake the JavaScript cookie setting by grabbing the cookie values from the JavaScript source and simply setting these cookies in the $agent->cookie_jar. Unfortunately, HTTP::Cookies->set_cookie() appears to simply overwrite a previous cookie having the same name, rather than saving an array of values for a cookie of a given name. So now I'm kinda stuck. Can the perluminati suggest a way my script can provide more than one cookie having the same name?

Replies are listed 'Best First'.
Re: Need same named cookies
by isotope (Deacon) on May 16, 2003 at 22:35 UTC
    What exactly are you passing HTTP::Cookies->set_cookie()?
    $cookie_jar->set_cookie($version, $key, $val, $path, $domain, $port, $path_spec, $secure, $maxage, $discard, \%rest) The set_cookie() method updates the state of the $cookie_jar. The $key, $val, $domain, $port and $path arguments are strings. The $path_spec, $secure, $dis­ card arguments are boolean values. The $maxage value is a number indicating number of seconds that this cookie will live. A value <= 0 will delete this cookie. %rest defines various other attributes like "Comment" and "CommentURL".
    Are you correctly parsing out the path and explicitly passing it to set_cookie()?

    --isotope
    http://www.skylab.org/~isotope/

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://258777]
Approved by The Mad Hatter
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-04-18 10:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found