By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,834 Members | 2,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,834 IT Pros & Developers. It's quick & easy.

set_cookie?

P: 31
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2. use LWP::UserAgent;
  3. use HTTP::Cookies;
  4. use strict;
  5. my $ua = LWP::UserAgent->new();
  6. my $cookie_jar = HTTP::Cookies->new();
  7. $ua->cookie_jar( $cookie_jar );
  8. $cookie_jar->set_cookie(
  9.   1,                     # version
  10.   'username',            # key
  11.   'jack',           # value
  12.   '/',                   # path
  13.   'http://www.example.com', # domain
  14.   '',                    # port
  15.   0,                     # path_spec
  16.   0,                     # secure
  17.   999999,                # maxage
  18.   0,                     # discard
  19.   {}                     # rest
  20.   );
  21. my $res = $ua->get("http://www.example.com/");
  22. if ($res->decoded_content=~/Your name is = (\w+)/i){
  23. print "name = $1";
  24. }
This script is supposed to log me on in some site, but when i compile it, it prints "name = null". Null would be default value for "Your name is = " in that site. Whats wrong in this script?
Nov 26 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.