How to print out the value of a Cookie?

M

marmot101

Hi, All,

Using CGI, I get a response from server which plant a Cookie in client
machine. Now I can get this Cookie, but I don't know how to print out the
value of this Cookie? I checked online manual, but seems none method works.
Can anyone help me?

Many thanks!

marmot101

############## My Source Code ####################
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Cookies;
use HTTP::Request::Common qw(POST);

my $agent = LWP::UserAgent->new();

my $url = 'http://***';
my $content = [ 'UserName' => '***', 'Password' => '***' ];
my $request = POST $url, $content;

my $response = $agent->request($request);

if ($response->is_success) {
print "Yes, it is success\n";
print $response->content;

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

# How to print out value of Cookie here?
# print "Cookie = ", $cookie_jar{'Stamp'}->value; # doesn't work
}
 
C

Charles DeRykus

Hi, All,

Using CGI, I get a response from server which plant a Cookie in client
machine. Now I can get this Cookie, but I don't know how to print out the
value of this Cookie? I checked online manual, but seems none method works.
....
# How to print out value of Cookie here?
# print "Cookie = ", $cookie_jar{'Stamp'}->value; # doesn't work
}

Perhaps the as_string method...?

print $cookie_jar->as_string
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top