in reply to (jeffa) Re: HTTP::Cookies with LWP::UserAgent
in thread HTTP::Cookies with LWP::UserAgent

Is there a way to save the cookie for later use? Or is that not possible when using LWP::UserAgent? Whenever it sends a request does it tell the server where to locate the cookie at? Thanks in advance.
  • Comment on Re: (jeffa) Re: HTTP::Cookies with LWP::UserAgent

Replies are listed 'Best First'.
(jeffa) 3Re: HTTP::Cookies with LWP::UserAgent
by jeffa (Bishop) on Jun 01, 2001 at 18:29 UTC
    Yes, you can save the cookie to a file by specifying a file name when you create the cookie object. If you only need the cookie around for the session, then you don't need to save it, unless you don't want to re-create it next time you run your bot.

    When a request is sent to the server, the cookie is neatly tucked away in the header of the request. That's how the server gets the cookie - through the browser (or the web bot in our case), which creates the header for the request.

    Jeff

    R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
    L-L--L-L--L-L--L-L--L-L--L-L--L-L--
    
      OK, so with my script i specify a file so that each request that is sent the server knows where to locate the cookie. In that case, Why would the server send a response saying it could not set a cookie even though it is set to the cookies.txt file? Is it possible that the server only allows IE and Netscape browsers ( I have the ua set as Mozilla/4.0) I'm still stumped as to why it would not set this cookie. Very stange.