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

Re: How can my script accept cookies?

by Daddio (Chaplain)
on May 15, 2001 at 01:23 UTC ( [id://80427]=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 How can my script accept cookies?

Admittedly, I don't have a whole lot of experience with cookies, especially in the manner you are working here. But, to summarize, here is what the LWP::UserAgent has to say about cookies:

$ua->cookie_jar([$cookies]) # Get/set the HTTP::Cookies object to use. The default # is to have no cookie_jar, i.e. never automatically add # "Cookie" headers to the requests.

In the LWP CookBook (man lwpcook), I found this (and it has some examples):

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.yahoo.no") +); print $res->status_line, "\n"; As you visit sites that send you cookies to keep, then the file lwpcookies.txt" will grow.

I don't know how much that will help since I can't give you any examples of my own, but I thought I would post it anyway. I have found reading the lwpcook and LWP::UserAgent documentation helpful in what I have done with LWP, so I recommend reading it if you haven't already.

D a d d i o

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://80427]
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.