GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  MOJO::USERAGENT::COOKIEJAR (3)

.ds Aq ’

NAME

Mojo::UserAgent::CookieJar - Cookie jar for HTTP user agents

CONTENTS

SYNOPSIS



  use Mojo::UserAgent::CookieJar;

  # Add response cookies
  my $jar = Mojo::UserAgent::CookieJar->new;
  $jar->add(
    Mojo::Cookie::Response->new(
      name   => foo,
      value  => bar,
      domain => localhost,
      path   => /test
    )
  );

  # Find request cookies
  for my $cookie (@{$jar->find(Mojo::URL->new(http://localhost/test))}) {
    say $cookie->name;
    say $cookie->value;
  }



DESCRIPTION

Mojo::UserAgent::CookieJar is a minimalistic and relaxed cookie jar used by Mojo::UserAgent, based on RFC 6265 <http://tools.ietf.org/html/rfc6265>.

ATTRIBUTES

Mojo::UserAgent::CookieJar implements the following attributes.

    ignore



  my $ignore = $jar->ignore;
  $jar       = $jar->ignore(sub {...});



A callback used to decide if a cookie should be ignored by collect.



  # Ignore all cookies
  $jar->ignore(sub { 1 });

  # Ignore cookies for domains "com", "net" and "org"
  $jar->ignore(sub {
    my $cookie = shift;
    return undef unless my $domain = $cookie->domain;
    return $domain eq com || $domain eq net || $domain eq org;
  });



    max_cookie_size



  my $size = $jar->max_cookie_size;
  $jar     = $jar->max_cookie_size(4096);



Maximum cookie size in bytes, defaults to 4096 (4KB).

METHODS

Mojo::UserAgent::CookieJar inherits all methods from Mojo::Base and implements the following new ones.

    add



  $jar = $jar->add(@cookies);



Add multiple Mojo::Cookie::Response objects to the jar.

    all



  my $cookies = $jar->all;



Return all Mojo::Cookie::Response objects that are currently stored in the jar.



  # Names of all cookies
  say $_->name for @{$jar->all};



    collect



  $jar->collect(Mojo::Transaction::HTTP->new);



Collect response cookies from transaction.

    empty



  $jar->empty;



Empty the jar.

    find



  my $cookies = $jar->find(Mojo::URL->new);



Find Mojo::Cookie::Request objects in the jar for Mojo::URL object.



  # Names of all cookies found
  say $_->name for @{$jar->find(Mojo::URL->new(http://example.com/foo))};



    prepare



  $jar->prepare(Mojo::Transaction::HTTP->new);



Prepare request cookies for transaction.

SEE ALSO

Mojolicious, Mojolicious::Guides, <http://mojolicious.org>.
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 MOJO::USERAGENT::COOKIEJAR (3) 2016-03-15

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.