Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Cookies

Reply
Thread Tools

Cookies

 
 
Tuba Chuck
Guest
Posts: n/a
 
      11-16-2004
Im trying to make a script that will login to my Pitas blog and then
post an entry. I seem to be having problems with the cookies. The
script is:
#!/usr/bin/perl
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
use HTTP::Cookies;

#Get needed info
print 'Login: ';
$uname = <STDIN>;
print 'Password: ';
$pass = <STDIN>;
print 'Date: ';
$date = <STDIN>;
print 'Time: ';
$time = <STDIN>;
print 'Title: ';
$pagename = <STDIN>;
print 'Entry: ';
$entry = <STDIN>;

$cookie_jar = HTTP::Cookies->new();

$login = LWP::UserAgent->new();
my $reql = POST 'http://www.pitas.com/cgi-bin/login.phtml', [
'username' => $uname, 'password' => $pass, 'remember_me' => 'no' ];
$responsel = $login->request($reql);

$addent = LWP::UserAgent->new();
my $requ = POST 'http://www.pitas.com/cgi-bin/update.phtml', [ 'date'
=> $date, 'time' => $time, 'url' => '#', 'pagename' => $pagename,
'entry' => $entry ];
$cookie_jar->add_cookie_header($requ);
$cookie_jar->extract_cookies($responsel);
$addent->request($requ);

exit;
 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      11-16-2004
Tuba Chuck <(E-Mail Removed)> wrote:

> I seem to be having problems with the cookies.
> script is:


> #!/usr/bin/perl


use warnings;
use strict;

Ask for all the help you can get!


> $cookie_jar = HTTP::Cookies->new();
>
> $login = LWP::UserAgent->new();



$login->cookie_jar($cookie_jar);

You never associated that cookie jar with the user agent.


> my $reql = POST 'http://www.pitas.com/cgi-bin/login.phtml', [
> 'username' => $uname, 'password' => $pass, 'remember_me' => 'no' ];
> $responsel = $login->request($reql);


> $addent = LWP::UserAgent->new();



Why do you need another UserAgent?

Just reuse $login.


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
 
Tuba Chuck
Guest
Posts: n/a
 
      11-16-2004
Tad McClellan <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>.. .
> Tuba Chuck <(E-Mail Removed)> wrote:
>
> > I seem to be having problems with the cookies.
> > script is:

>
> > #!/usr/bin/perl

>
> use warnings;
> use strict;
>
> Ask for all the help you can get!
>
>
> > $cookie_jar = HTTP::Cookies->new();
> >
> > $login = LWP::UserAgent->new();

>
>
> $login->cookie_jar($cookie_jar);
>
> You never associated that cookie jar with the user agent.
>
>
> > my $reql = POST 'http://www.pitas.com/cgi-bin/login.phtml', [
> > 'username' => $uname, 'password' => $pass, 'remember_me' => 'no' ];
> > $responsel = $login->request($reql);

>
> > $addent = LWP::UserAgent->new();

>
>
> Why do you need another UserAgent?
>
> Just reuse $login.


Thanks!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Give Request.Cookies and Response.Cookies is there any reason to use another method to use cookies? _Who ASP .Net 7 09-18-2008 07:49 PM
What's the proper way of reading cookies? Request.Cookies("mycook") doesnt work user ASP .Net 3 03-31-2007 01:53 PM
Response.Cookies vs Request.Cookies Alex Nitulescu ASP .Net 1 02-03-2005 09:43 AM
Persistent Cookies vs. session cookies Andy Fish Java 3 11-06-2003 10:44 AM
Good Cookies bad Cookies? AK Computer Support 23 10-26-2003 05:20 AM



Advertisments