logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

APR::Request::Cookie - wrapper for libapreq2's cookie API.

Description

       The APR::Request::Cookie module provides base methods for interfacing with libapreq2's cookie API.  It
       also provides a few utility functions and constants.

       This manpage documents version 2.17 of the APR::Request::Cookie package.

Methods

       APR::Request::Cookie

   new
           APR::Request::Cookie->new($pool,
                                      name => $name,
                                     value => $value,
                                     %args)

       Creates a new cookie.  Here $pool is an APR::Pool object, and $name is the cookie's name. The $value is
       transformed into the cookie's raw value through the class' freeze() method.  The remaining arguments are
       optional:

       -secure
       -httponly
       -version
       -path
       -domain
       -port
       -expires
       -comment
       -commentURL

       For details on these arguments, please consult the corresponding method's documentation.

   freeze
           APR::Request::Cookie->freeze($value)

       Class method representing the default serializer; here it returns $value unmodified.

           ok "foo" eq APR::Request::Cookie->freeze("foo");

   thaw
           $cookie->thaw()

       Reverses freeze(); here it simply returns $cookie->value since freeze() is a noop.

           ok $cookie->thaw eq $cookie->value;

   name
           $cookie->name()

       Fetch  the  cookie's  name.   This  attribute cannot be modified and is never serialized; ie freeze() and
       thaw() do not act on the cookie's name.

   value
           $cookie->value()

       Fetch the cookie's raw (frozen) value.  This attribute cannot be modified.

   secure
           $cookie->secure()
           $cookie->secure($set)

       Get/set the cookie's secure flag.

           $cookie->secure(1);
           ok $cookie->secure == 1;

   httponly
           $cookie->httponly()
           $cookie->httponly($set)

       Get/set the cookie's HttpOnly flag.

           $cookie->httponly(1);
           ok $cookie->httponly == 1;

   version
           $cookie->version()
           $cookie->version($set)

       Get/set the cookie's version number.  Version 0 cookies conform to the Netscape spec; Version  1  cookies
       conform to either RFC 2109 or RFC 2965.

           $version = $cookie->version;
           $cookie->version(1);
           ok $cookie->version == 1;

   path
           $cookie->path()
           $cookie->path($set)

       Get/set the cookie's path string.

           $path = $cookie->path;
           $cookie->path("/1/2/3/4");
           ok $cookie->path eq "/1/2/3/4";

   domain
           $cookie->domain()
           $cookie->domain($set)

       Get/set the cookie's domain string.

           $domain = $cookie->domain;
           $cookie->domain("apache.org");
           ok $cookie->domain eq "apache.org";

   port
           $cookie->port()
           $cookie->port($set)

       Get/set the cookie's port string.  Only valid for Version 1 cookies.

           $port = $cookie->port;
           $cookie->port(8888);
           ok $cookie->port == 8888;

   comment
           $cookie->comment()
           $cookie->comment($set)

       Get/set the cookie's comment string.  Only valid for Version 1 cookies.

           $comment = $cookie->comment;
           $cookie->comment("quux");
           ok $cookie->comment eq "quux";

   commentURL
           $cookie->commentURL()
           $cookie->commentURL($set)

       Get/set the cookie's commentURL string.  Only valid for Version 1 cookies.

           $commentURL = $cookie->commentURL;
           $cookie->commentURL("/foo/bar");
           ok $cookie->commentURL eq "/foo/bar";

   is_tainted
           $cookie->is_tainted()
           $cookie->is_tainted($set)

       Get/set the cookie's internal tainted flag.

           $tainted = $cookie->is_tainted;
           $cookie->is_tainted(1);
           ok $cookie->is_tainted == 1;

   make
           APR::Request::Cookie->make($pool, $name, $value)

       Fast  XS  cookie constructor invoked by new().  The cookie's raw name & value are taken directly from the
       passed in arguments; no freezing/encoding is done on the $value.

   as_string
           $cookie->as_string()

       String representation of the cookie, suitable for inclusion in a "Set-Cookie" header.

           print "Set-Cookie: ", $cookie->as_string, "\n";

Name

       APR::Request::Cookie - wrapper for libapreq2's cookie API.

Overloads

       APR::Request::Cookie

   ""
           "$cookie"

       The double-quote interpolation operator maps to APR::Request::Cookie::value().

           ok "$cookie" eq $cookie->value;

See Also

       Apache2::Cookie, APR::Request.

Subroutines

         APR::Request::Cookie

   expires
         expires($date_string)

Synopsis

         use APR::Request::Cookie;

         # fetch inbound cookie
         $jar = $req->jar;
         $cookie1 = $jar->get("cookie1");

         # generate new cookie
         $cookie = APR::Request::Cookie->new($req->pool,
                                             name => "foo",
                                            value => "bar",
                                           domain => "capricorn.com");
         print "$cookie"; # prints "bar"

         $cookie->domain("example.com"); # change domains
         $cookie->version(1); # upgrade it to conform with RFC 2109/2965.

         # send a response header
         print sprintf "Set-Cookie: %s\n", $cookie->as_string;

See Also