Cookie(3pm)

✨ NAME ✨

hii bestie, you've landed on the Cookie(3pm) page πŸ’– and this one is the manual for APR::Request::Cookie β€” literally just a wrapper for libapreq2's cookie API. that's the whole gig, no cap. πŸͺ


πŸŽ€ 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;

okay so real quick: you can grab an inbound cookie off the jar, you can spin up a brand new one, you can poke at its fields, and you can turn it back into a Set-Cookie header when you're done. the whole character arc ✨


🌸 DESCRIPTION 🌸

The APR::Request::Cookie module provides base methods for interfacing with libapreq2's cookie API. it also tosses in a few utility functions and constants, because why not, iconic behavior πŸ’…

This manpage documents version 2.17 of the APR::Request::Cookie package. yes, specifically that one, don't @ me 🫢


🌈 OVERLOADS 🌈

APR::Request::Cookie

πŸͺž ""

"$cookie"

The double-quote interpolation operator maps to APR::Request::Cookie::value(). so when you stringify it, you get the value, periodt.

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

πŸ’… METHODS πŸ’…

APR::Request::Cookie

🧚 new

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

Creates a new cookie, bestie. here $pool is an APR::Pool object, and $name is the cookie's name. the $value gets transformed into the cookie's raw value through the class' freeze() method β€” so it goes through the glow-up machine. ✨

the remaining arguments are all optional:

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

for the deets on any of these, go consult the corresponding method's documentation down below. it's all there, i would never gatekeep πŸ™ˆ

❄️ freeze

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

Class method representing the default serializer. here it just returns $value unmodified β€” zero drama, no transformation, we love a no-op.

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

πŸ”₯ thaw

$cookie->thaw()

Reverses freeze(). here it simply returns $cookie->value since freeze() is a noop β€” so it's giving "undo button that does nothing because nothing was done" 😭

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

🏷️ name

$cookie->name()

Fetch the cookie's name. this attribute cannot be modified and is never serialized β€” i.e. freeze() and thaw() do not act on the cookie's name. it's just vibing off to the side, untouched. πŸ‘‘

πŸ’Ž value

$cookie->value()

Fetch the cookie's raw (frozen) value. this attribute cannot be modified either. look, don't touch. 🫢

πŸ”’ 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. heads up: Version 0 cookies conform to the Netscape spec, and Version 1 cookies conform to either RFC 2109 or RFC 2965. know which era your cookie is living in, bestie πŸ•°οΈ

$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 β€” so if you're on Version 0, this is not your moment.

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

πŸ’¬ comment

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

Get/set the cookie's comment string. ⚠️ again, 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. ⚠️ and yes, only valid for Version 1 cookies. noticing a pattern? it's the Version 1 club πŸ’œ

$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 β€” and no freezing/encoding is done on the $value. so it's fast, it's raw, it's the no-frills version. no filter, no glow-up, straight in. πŸ”₯

🎁 as_string

$cookie->as_string()

String representation of the cookie, suitable for inclusion in a "Set-Cookie" header. this is the one you print when you're shipping it back out into the world, slay.

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

πŸ“ SUBROUTINES πŸ“

APR::Request::Cookie

πŸ“… expires

expires($date_string)

πŸ¦‹ SEE ALSO πŸ¦‹

  • Apache2::Cookie
  • APR::Request

two little besties for the road 🫢


Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

and that's the whole page, bestie πŸŽ€ this one was perl v5.42.3, dated 2026-08-21 β€” go forth and cookie responsibly πŸ’–πŸͺ✨

πŸ“¦ where this page comes from