1Cookie(3)             User Contributed Perl Documentation            Cookie(3)
2
3
4

NAME

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

SYNOPSIS

9         use APR::Request::Cookie;
10
11         # fetch inbound cookie
12         $jar = $req->jar;
13         $cookie1 = $jar->get("cookie1");
14
15         # generate new cookie
16         $cookie = APR::Request::Cookie->new($req->pool,
17                                             name => "foo",
18                                            value => "bar",
19                                           domain => "capricorn.com");
20         print "$cookie"; # prints "bar"
21
22         $cookie->domain("example.com"); # change domains
23         $cookie->version(1); # upgrade it to conform with RFC 2109/2965.
24
25         # send a response header
26         print sprintf "Set-Cookie: %s\n", $cookie->as_string;
27

DESCRIPTION

29       The APR::Request::Cookie module provides base methods for interfacing
30       with libapreq2's cookie API.  It also provides a few utility functions
31       and constants.
32
33       This manpage documents version 2.13 of the APR::Request::Cookie
34       package.
35

OVERLOADS

37       APR::Request::Cookie
38
39   ""
40           "$cookie"
41
42       The double-quote interpolation operator maps to
43       "APR::Request::Cookie::value()".
44
45           ok "$cookie" eq $cookie->value;
46

METHODS

48       APR::Request::Cookie
49
50   new
51           APR::Request::Cookie->new($pool,
52                                      name => $name,
53                                     value => $value,
54                                     %args)
55
56       Creates a new cookie.  Here $pool is an APR::Pool object, and $name is
57       the cookie's name. The $value is transformed into the cookie's raw
58       value through the class' "freeze()" method.  The remaining arguments
59       are optional:
60
61       -secure
62       -httponly
63       -version
64       -path
65       -domain
66       -port
67       -expires
68       -comment
69       -commentURL
70
71       For details on these arguments, please consult the corresponding
72       method's documentation.
73
74   freeze
75           APR::Request::Cookie->freeze($value)
76
77       Class method representing the default serializer; here it returns
78       $value unmodified.
79
80           ok "foo" eq APR::Request::Cookie->freeze("foo");
81
82   thaw
83           $cookie->thaw()
84
85       Reverses "freeze()"; here it simply returns $cookie->value since
86       freeze() is a noop.
87
88           ok $cookie->thaw eq $cookie->value;
89
90   name
91           $cookie->name()
92
93       Fetch the cookie's name.  This attribute cannot be modified and is
94       never serialized; ie freeze() and thaw() do not act on the cookie's
95       name.
96
97   value
98           $cookie->value()
99
100       Fetch the cookie's raw (frozen) value.  This attribute cannot be
101       modified.
102
103   secure
104           $cookie->secure()
105           $cookie->secure($set)
106
107       Get/set the cookie's secure flag.
108
109           $cookie->secure(1);
110           ok $cookie->secure == 1;
111
112   httponly
113           $cookie->httponly()
114           $cookie->httponly($set)
115
116       Get/set the cookie's HttpOnly flag.
117
118           $cookie->httponly(1);
119           ok $cookie->httponly == 1;
120
121   version
122           $cookie->version()
123           $cookie->version($set)
124
125       Get/set the cookie's version number.  Version 0 cookies conform to the
126       Netscape spec; Version 1 cookies conform to either RFC 2109 or RFC
127       2965.
128
129           $version = $cookie->version;
130           $cookie->version(1);
131           ok $cookie->version == 1;
132
133   path
134           $cookie->path()
135           $cookie->path($set)
136
137       Get/set the cookie's path string.
138
139           $path = $cookie->path;
140           $cookie->path("/1/2/3/4");
141           ok $cookie->path eq "/1/2/3/4";
142
143   domain
144           $cookie->domain()
145           $cookie->domain($set)
146
147       Get/set the cookie's domain string.
148
149           $domain = $cookie->domain;
150           $cookie->domain("apache.org");
151           ok $cookie->domain eq "apache.org";
152
153   port
154           $cookie->port()
155           $cookie->port($set)
156
157       Get/set the cookie's port string.  Only valid for Version 1 cookies.
158
159           $port = $cookie->port;
160           $cookie->port(8888);
161           ok $cookie->port == 8888;
162
163   comment
164           $cookie->comment()
165           $cookie->comment($set)
166
167       Get/set the cookie's comment string.  Only valid for Version 1 cookies.
168
169           $comment = $cookie->comment;
170           $cookie->comment("quux");
171           ok $cookie->comment eq "quux";
172
173   commentURL
174           $cookie->commentURL()
175           $cookie->commentURL($set)
176
177       Get/set the cookie's commentURL string.  Only valid for Version 1
178       cookies.
179
180           $commentURL = $cookie->commentURL;
181           $cookie->commentURL("/foo/bar");
182           ok $cookie->commentURL eq "/foo/bar";
183
184   is_tainted
185           $cookie->is_tainted()
186           $cookie->is_tainted($set)
187
188       Get/set the cookie's internal tainted flag.
189
190           $tainted = $cookie->is_tainted;
191           $cookie->is_tainted(1);
192           ok $cookie->is_tainted == 1;
193
194   make
195           APR::Request::Cookie->make($pool, $name, $value)
196
197       Fast XS cookie constructor invoked by "new()".  The cookie's raw name &
198       value are taken directly from the passed in arguments; no
199       freezing/encoding is done on the $value.
200
201   as_string
202           $cookie->as_string()
203
204       String representation of the cookie, suitable for inclusion in a "Set-
205       Cookie" header.
206
207           print "Set-Cookie: ", $cookie->as_string, "\n";
208

SUBROUTINES

210         APR::Request::Cookie
211
212   expires
213         expires($date_string)
214

SEE ALSO

216       Apache2::Cookie, APR::Request.
217
219         Licensed to the Apache Software Foundation (ASF) under one or more
220         contributor license agreements.  See the NOTICE file distributed with
221         this work for additional information regarding copyright ownership.
222         The ASF licenses this file to You under the Apache License, Version 2.0
223         (the "License"); you may not use this file except in compliance with
224         the License.  You may obtain a copy of the License at
225
226             http://www.apache.org/licenses/LICENSE-2.0
227
228         Unless required by applicable law or agreed to in writing, software
229         distributed under the License is distributed on an "AS IS" BASIS,
230         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
231         See the License for the specific language governing permissions and
232         limitations under the License.
233
234
235
236perl v5.28.1                      2019-02-01                         Cookie(3)
Impressum