Hi,
I dealt with cookies two weeks ago by coinsidence.
below is a subroutine that I used to log in to a site with a certain account
and fetch information from that account. (It's an online multiplayer game)
Hopefully you are able to understand the mechanism used so you can implement
cookies for your situation.
I know it is possible for example to save the cookies to disk for later
retreival, but I haven't done that yet.
Regards, Thor.
use strict;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Cookies;
sub get_info {
my ($user, $pass) = @_;
my $cookies = new HTTP::Cookies;
my $ua = new LWP::UserAgent;
my $req;
my $res;
$req = new HTTP::Request (POST =>
'http://ambar.coldfirestudios.com/game/login');
$req->content_type('application/x-www-form-urlencoded');
$req->content("Username=$user&Password=$pass");
$res = $ua->request($req);
$cookies->extract_cookies($res);
$req = new HTTP::Request (GET =>
'http://ambar.coldfirestudios.com/game/mainmenu');
$cookies->add_cookie_header($req);
$res = $ua->request($req);
return $res->content;
}
Groeten, Regards, Salutations,
Thor Spruyt
System Integrator
Siemens Atea Herentals IC D CN C
Tel: +32 (0)14 25 66 97
Mobile: +32 (0)475 67 22 65 (priv)
Email: [EMAIL PROTECTED]
-----Original Message-----
From: Nicolas M�nant [mailto:[EMAIL PROTECTED]]
Sent: zaterdag 6 april 2002 19:06
To: [EMAIL PROTECTED]
Subject: accept cookie
hi,
i wanna create a program (under FreeBSD) that log me automatically on a site
but i need to accept cookie tu do this:
use LWP::UserAgent;
use HTTP::Cookies;
$ua = LWP::UserAgent->new;
$ua->cookie_jar(HTTP::Cookies->new);
my $req=HTTP::Request->new(POST => 'http://www.toto.fr);
$req->content_type('application/x-www-form-urlencoded');
$req->content('login=toto&pass=titi');
my $res = $ua->request($req);
if ($res->is_success)
{
print $res->content:
}
but the page i receive is a page that says me that i haven't enable cookie
on my computer...
if anyone has an idea ...he's welcome!!
Thanks
Nico