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.09 of the APR::Request::Cookie pack‐
34       age.
35

OVERLOADS

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

METHODS

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

SUBROUTINES

216         APR::Request::Cookie
217
218       expires
219
220         expires($date_string)
221

SEE ALSO

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