Cookie problem ?

Cookie problem ?

am 14.06.2005 17:01:13 von Robert.L.Harris

I'm trying to write a script that will log me into a page and click a
link. I've got the logic down but it's been complaining about
cookies. Using LWP::Debug I'm getting this:


LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking www.studiotraffic.com for cookie=
s
HTTP::Cookies::add_cookie_header: Checking .studiotraffic.com for cookies
HTTP::Cookies::add_cookie_header: Checking studiotraffic.com for cookies
HTTP::Cookies::add_cookie_header: Checking .com for cookies
LWP::UserAgent::send_request: GET http://www.studiotraffic.com/index.php
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 558 bytes
LWP::Protocol::collect: read 1872 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 2896 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 2896 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 2896 bytes
LWP::Protocol::collect: read 2896 bytes
LWP::Protocol::collect: read 2896 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 1925 bytes
HTTP::Cookies::extract_cookies: Set cookie PHPSESSID =3D>
35db73c36b129dd2f9e5e0b6003a2d41
LWP::UserAgent::request: Simple response: OK
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking www.studiotraffic.com for cookie=
s
HTTP::Cookies::add_cookie_header: - checking cookie path=3D/
HTTP::Cookies::add_cookie_header: - checking cookie
PHPSESSID=3D35db73c36b129dd2f9e5e0b6003a2d41
HTTP::Cookies::add_cookie_header: it's a match
HTTP::Cookies::add_cookie_header: Checking .studiotraffic.com for cookies
HTTP::Cookies::add_cookie_header: Checking studiotraffic.com for cookies
HTTP::Cookies::add_cookie_header: Checking .com for cookies
LWP::UserAgent::send_request: POST http://www.studiotraffic.com/checkuser.p=
hp
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 2 bytes
LWP::UserAgent::request: Simple response: Found
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking www.studiotraffic.com for cookie=
s
HTTP::Cookies::add_cookie_header: - checking cookie path=3D/
HTTP::Cookies::add_cookie_header: - checking cookie
PHPSESSID=3D35db73c36b129dd2f9e5e0b6003a2d41
HTTP::Cookies::add_cookie_header: it's a match
HTTP::Cookies::add_cookie_header: Checking .studiotraffic.com for cookies
HTTP::Cookies::add_cookie_header: Checking studiotraffic.com for cookies
HTTP::Cookies::add_cookie_header: Checking .com for cookies
LWP::UserAgent::send_request: GET
http://www.studiotraffic.com/login.php?invalid=3D1
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 554 bytes
LWP::Protocol::collect: read 1872 bytes
LWP::Protocol::collect: read 1872 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 2936 bytes
LWP::Protocol::collect: read 1017 bytes
LWP::Protocol::collect: read 384 bytes
LWP::Protocol::collect: read 2456 bytes
HTTP::Cookies::extract_cookies: Set cookie Cusername =3D> deleted
LWP::UserAgent::request: Simple response: OK

The script is VERY simple at this point:

#!/usr/bin/perl -w

my ($TopURL)=3D"http://www.website.com/index.php";
use WWW::Mechanize;
use LWP::Debug qw(+);
my $mech =3D WWW::Mechanize->new( );

$mech->get( $TopURL ) || die "Can't Connect to $TopURL : $!";

#
my ($UserName)=3D"Foo";
my ($Passwd)=3D"Bar";


# Log in.
$mech->submit_form(
form_number =3D> 1,
fields =3D> { 'username' =3D> '$UserName', 'password' =3D> '$Passwd'
}
);
print $mech->content();



Anyone have any ideas? I've tried a couple things such as:
use HTTP::Cookies;
my $mech =3D WWW::Mechanize->new( autocheck=3D>1, cookie_jar=3D>{ file =3D>
"$ENV{HOME}/.cookies.txt"} );
$mech->cookie_jar(HTTP::Cookies->new());

No noticable difference.

Any ideas?
Robert
--=20

:wq!
------------------------------------------------------------ ---------------
Robert L. Harris

DISCLAIMER:
These are MY OPINIONS With Dreams To Be A King,
ALONE. I speak for First One Should Be A Man
no-one else. - Manowar