How to print out the value of a Cookie?

Discussion in 'Perl Misc' started by marmot101, Jul 29, 2003.

  1. marmot101

    marmot101 Guest

    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
    }
     
    marmot101, Jul 29, 2003
    #1
    1. Advertising

  2. In article <BVzVa.78$>,
    marmot101 <> wrote:
    >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

    --
    Charles DeRykus
     
    Charles DeRykus, Aug 18, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. keto
    Replies:
    0
    Views:
    1,043
  2. David Cournapeau

    print a vs print '%s' % a vs print '%f' a

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    399
    David Cournapeau
    Dec 30, 2008
  3. terry
    Replies:
    2
    Views:
    89
    Janwillem Borleffs
    Jul 31, 2003
  4. Antonio Quinonez
    Replies:
    2
    Views:
    192
    Antonio Quinonez
    Aug 14, 2003
  5. iMath
    Replies:
    2
    Views:
    168
    Peter Otten
    Dec 26, 2012
Loading...

Share This Page