Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
P is for Practical
 
PerlMonks  

Re: Embedding cookies in requests

by Fletch (Bishop)
on May 07, 2002 at 13:57 UTC ( [id://164759]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Embedding cookies in HTTP requests

$ perldoc lwpcook [...] COOKIES Some sites like to play games with cookies. By default LWP ignores cookies provided by the servers it visits. LWP will collect cookies and respond to cookie requests if you set up a cookie jar. use LWP::UserAgent; use HTTP::Cookies; $ua = LWP::UserAgent->new; $ua->cookie_jar(HTTP::Cookies->new(file => "lwpcookies.txt", autosave => 1)); # and then send requests just as you used to do $res = $ua->request(HTTP::Request->new(GET => "http://www.yah +oo.no")); print $res->status_line, "\n"; [...]

Looks rather complete and simple to me. HTTP::Cookies is also well documented.

Replies are listed 'Best First'.
Re: Re: Embedding cookies in requests
by Torgo (Beadle) on May 07, 2002 at 15:07 UTC
    Yes, I'm well aware of Cookie::Jar. I'm looking for a solution that will let me send cookies that I create on the fly to simulate different users, not something to store cookies in.
    And if I wanted to be talked down to, I would have bought Perl for Dummies.
    --
    I write the code while the master is away!

      Perhaps if you read the documentation harder, you'd see that HTTP::Cookies has a set_cookie method which allows you to add cookies to a jar dynamically. You then use add_cookie_header to add the correct headers to a request object.

      And Perl for Dummies wouldn't help you either if you read it half as well as you've apparently read the HTTP::Cookies and LWP documentation.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://164759]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.