Hi Gavin: I actually was able to fetch the html pages that the php script generates after login in. I can also submit to forms within the admin area and capture the resulting html sent from the php script.
The solution I used before your email is simply: $cookie_jar = HTTP::Cookies->new(); $browser->cookie_jar( $cookie_jar ); With yours below: $browser->cookie_jar(HTTP::Cookies->new(file => 'cookies.txt', autosave => 1, ignore_discard => 1)); Is it safe to use "autosave" ? I will probably end up using yours. Another question, when do we actually use the authentication one (the one that specifies username, password, realm etc ...) ? Cheers Louis. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Gavin Carr Sent: Wednesday, December 04, 2002 08:44 AM To: [EMAIL PROTECTED] Subject: Re: [SLUG] Perl and LWP::UserAgent With Cookies Support Hi Louis, On Mon, Dec 02, 2002 at 09:28:08PM +1100, Louis Selvon wrote: > For the headers I see this: > > Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 > Connection: close > Date: Sun, 01 Dec 2002 06:08:04 GMT <snip> > Set-Cookie: PHPSESSID=3de06093c289ef6f2b07dd47c73594e1; path=/ > > By the looks of this, they are using a Cookie for the current session. The LWP cookie jar should handle this cookie fine if you set it up (see below). > For the html returned, it just returned the following: > > <html> > <head><title>Login</title> > <script language="javascript"> > function setCookie(name,value,days) > { > var expires = new Date(); > expires.setTime(expires.getTime() + days*24*60*60*1000); > document.cookie = name + "=" +value + > ((expires == null) ? "" : "; expires=" + expires.toGMTString()) ; > }//eof function setCookie() > </script> > > </head> > > <body> > <script>document.location='inside_home.php';</script> > </body> > </html> This setCookie function is to set a cookie from javascript, but it isn't actually used. But be aware that if they do use thing function on other pages you won't pick the cookie up, because it's being done client-side (by the javascript), not server-side (which is what you really need for LWP). > I do not see the html code that I see from my browser. I just see the php > script name. > > Problem 1: > How do I get the script to return the html code for the php script ? I'm not sure what you mean here. Do you mean you want the php source? > Problem 2: > For the cookies that was set, how do I set the Cookie jar to use this session > for all my requests ? If I add the following line when I create the "$browser" > object, will it work: > > $browser->cookie_jar( {} ); I usually do something like: $browser->cookie_jar(HTTP::Cookies->new(file => 'cookies.txt', autosave => 1, ignore_discard => 1)); Tweak the HTTP::Cookies parameters to taste - ignore_discard is useful for keeping session-only cookies around for debugging. Cheers, Gavin -- Open Fusion P/L - Open Source Business Solutions [ Linux - Perl - Apache ] http://www.openfusion.com.au - Fashion is a variable, but style is a constant - Programming Perl -- SLUG - Sydney Linux User's Group - http://slug.org.au/ More Info: http://lists.slug.org.au/listinfo/slug -- SLUG - Sydney Linux User's Group - http://slug.org.au/ More Info: http://lists.slug.org.au/listinfo/slug
