Apache HTTP Server Request Library
APR::Request::Cookie - wrapper for libapreq2's cookie API.
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;
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 the APR::Request::Cookie and APR::Request::Cookie::Table packages.
APR::Request::Cookie
"$cookie"
The double-quote interpolation operator maps to
APR::Request::Cookie::value()
.
APR::Request::Cookie
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:
For details on these arguments, please consult the corresponding method's documentation.
APR::Request::Cookie->freeze($value)
Class method representing the default serializer; here it returns $value unmodified.
APR::Request::Cookie->thaw($value)
Class method that reverses freeze()
;
here it returns $value unmodified.
$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.
$cookie->value()
Fetch the cookie's raw (frozen) value. This attribute cannot be modified.
$cookie->secure() $cookie->secure($set)
Get/set the cookie's secure flag.
$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.
$cookie->path() $cookie->path($set)
Get/set the cookie's path string.
$cookie->domain() $cookie->domain($set)
Get/set the cookie's domain string.
$cookie->port() $cookie->port($set)
Get/set the cookie's port string. Only valid for Version 1 cookies.
$cookie->comment() $cookie->comment($set)
Get/set the cookie's comment string. Only valid for Version 1 cookies.
$cookie->commentURL() $cookie->commentURL($set)
Get/set the cookie's commentURL string. Only valid for Version 1 cookies.
$cookie->is_tainted() $cookie->is_tainted($set)
Get/set the cookie's internal tainted flag.
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.
$cookie->as_string()
String representation of the cookie, suitable for inclusion in a ``Set-Cookie'' header.
APR::Request::Cookie
expires($date_string)
APR::Request::Cookie::Table - read-only version of APR::Table.
Tables in this class normally arise from calls to
APR::Request::jar()
.
$table->cookie_class() $table->cookie_class($set)
Get/set the class each table element is blessed into during a the get manpage or FETCH call. If defined, the class must be derived from APR::Request::Cookie. When called with $set, it returns the $table. Otherwise it returns the name of the current class, or undef if no cookie class is defined.
{ package FOO; @ISA= 'APR::Request::Cookie'; }
$jar->cookie_class("FOO"); ok $_->isa("FOO") for values %$jar;
$table->get($key)
Same as FETCH.
$table->FETCH($key)
In scalar context, this returns the first value matching $key (note: see NEXTKEY for additional notes). The match is always case-insensitive. In list context, this returns all matching values. Note: the type of the return values depends on the table's current cookie_class.
Synonym for defined
; these tables are not
allowed to contain undefined values. Since these
are constant tables, they don't autovivify either.
$table->FIRSTKEY()
Returns the first key in the table.
$table->NEXTKEY()
Returns the next key in the table. For perl 5.8+, if the key is multivalued, a subsequent FETCH on this key will return the corresponding value, until either NEXTKEY or FIRSTKEY is invoked again. For perl 5.6, FETCH always returns the first value.
$table->do($callback, @keys)
Same as APR::Table::do; iterates over the table calling $callback->($key, $value) for each matching @keys. If @keys is empty, this iterates over the entire table.
Note: The type of $value inserted into the callback depends on the table's current cookie_class.
the Apache2::Cookie manpage, the APR::Request manpage, the APR::Table manpage.
Copyright 2003-2005 The Apache Software Foundation
Licensed 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.