Commit | Line | Data |
3fea05b9 |
1 | .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.3 |
2 | .\" |
3 | .\" Standard preamble: |
4 | .\" ======================================================================== |
5 | .de Sh \" Subsection heading |
6 | .br |
7 | .if t .Sp |
8 | .ne 5 |
9 | .PP |
10 | \fB\\$1\fR |
11 | .PP |
12 | .. |
13 | .de Sp \" Vertical space (when we can't use .PP) |
14 | .if t .sp .5v |
15 | .if n .sp |
16 | .. |
17 | .de Vb \" Begin verbatim text |
18 | .ft CW |
19 | .nf |
20 | .ne \\$1 |
21 | .. |
22 | .de Ve \" End verbatim text |
23 | .ft R |
24 | .fi |
25 | .. |
26 | .\" Set up some character translations and predefined strings. \*(-- will |
27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left |
28 | .\" double quote, and \*(R" will give a right double quote. | will give a |
29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to |
30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' |
31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. |
32 | .tr \(*W-|\(bv\*(Tr |
33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' |
34 | .ie n \{\ |
35 | . ds -- \(*W- |
36 | . ds PI pi |
37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch |
38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch |
39 | . ds L" "" |
40 | . ds R" "" |
41 | . ds C` "" |
42 | . ds C' "" |
43 | 'br\} |
44 | .el\{\ |
45 | . ds -- \|\(em\| |
46 | . ds PI \(*p |
47 | . ds L" `` |
48 | . ds R" '' |
49 | 'br\} |
50 | .\" |
51 | .\" If the F register is turned on, we'll generate index entries on stderr for |
52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index |
53 | .\" entries marked with X<> in POD. Of course, you'll have to process the |
54 | .\" output yourself in some meaningful fashion. |
55 | .if \nF \{\ |
56 | . de IX |
57 | . tm Index:\\$1\t\\n%\t"\\$2" |
58 | .. |
59 | . nr % 0 |
60 | . rr F |
61 | .\} |
62 | .\" |
63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes |
64 | .\" way too many mistakes in technical documents. |
65 | .hy 0 |
66 | .if n .na |
67 | .\" |
68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). |
69 | .\" Fear. Run. Save yourself. No user-serviceable parts. |
70 | . \" fudge factors for nroff and troff |
71 | .if n \{\ |
72 | . ds #H 0 |
73 | . ds #V .8m |
74 | . ds #F .3m |
75 | . ds #[ \f1 |
76 | . ds #] \fP |
77 | .\} |
78 | .if t \{\ |
79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) |
80 | . ds #V .6m |
81 | . ds #F 0 |
82 | . ds #[ \& |
83 | . ds #] \& |
84 | .\} |
85 | . \" simple accents for nroff and troff |
86 | .if n \{\ |
87 | . ds ' \& |
88 | . ds ` \& |
89 | . ds ^ \& |
90 | . ds , \& |
91 | . ds ~ ~ |
92 | . ds / |
93 | .\} |
94 | .if t \{\ |
95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" |
96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' |
97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' |
98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' |
99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' |
100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' |
101 | .\} |
102 | . \" troff and (daisy-wheel) nroff accents |
103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' |
104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' |
105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] |
106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' |
107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' |
108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] |
109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] |
110 | .ds ae a\h'-(\w'a'u*4/10)'e |
111 | .ds Ae A\h'-(\w'A'u*4/10)'E |
112 | . \" corrections for vroff |
113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' |
114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' |
115 | . \" for low resolution devices (crt and lpr) |
116 | .if \n(.H>23 .if \n(.V>19 \ |
117 | \{\ |
118 | . ds : e |
119 | . ds 8 ss |
120 | . ds o a |
121 | . ds d- d\h'-1'\(ga |
122 | . ds D- D\h'-1'\(hy |
123 | . ds th \o'bp' |
124 | . ds Th \o'LP' |
125 | . ds ae ae |
126 | . ds Ae AE |
127 | .\} |
128 | .rm #[ #] #H #V #F C |
129 | .\" ======================================================================== |
130 | .\" |
131 | .IX Title "HTTP::Cookies 3" |
132 | .TH HTTP::Cookies 3 "2009-10-06" "perl v5.8.7" "User Contributed Perl Documentation" |
133 | .SH "NAME" |
134 | HTTP::Cookies \- HTTP cookie jars |
135 | .SH "SYNOPSIS" |
136 | .IX Header "SYNOPSIS" |
137 | .Vb 5 |
138 | \& use HTTP::Cookies; |
139 | \& $cookie_jar = HTTP::Cookies\->new( |
140 | \& file => "$ENV{'HOME'}/lwp_cookies.dat', |
141 | \& autosave => 1, |
142 | \& ); |
143 | .Ve |
144 | .PP |
145 | .Vb 3 |
146 | \& use LWP; |
147 | \& my $browser = LWP::UserAgent\->new; |
148 | \& $browser\->cookie_jar($cookie_jar); |
149 | .Ve |
150 | .PP |
151 | Or for an empty and temporary cookie jar: |
152 | .PP |
153 | .Vb 3 |
154 | \& use LWP; |
155 | \& my $browser = LWP::UserAgent\->new; |
156 | \& $browser\->cookie_jar( {} ); |
157 | .Ve |
158 | .SH "DESCRIPTION" |
159 | .IX Header "DESCRIPTION" |
160 | This class is for objects that represent a \*(L"cookie jar\*(R" \*(-- that is, a |
161 | database of all the \s-1HTTP\s0 cookies that a given LWP::UserAgent object |
162 | knows about. |
163 | .PP |
164 | Cookies are a general mechanism which server side connections can use |
165 | to both store and retrieve information on the client side of the |
166 | connection. For more information about cookies refer to |
167 | <URL:http://curl.haxx.se/rfc/cookie_spec.html> and |
168 | <URL:http://www.cookiecentral.com/>. This module also implements the |
169 | new style cookies described in \fI\s-1RFC\s0 2965\fR. |
170 | The two variants of cookies are supposed to be able to coexist happily. |
171 | .PP |
172 | Instances of the class \fIHTTP::Cookies\fR are able to store a collection |
173 | of Set\-Cookie2: and Set\-Cookie: headers and are able to use this |
174 | information to initialize Cookie-headers in \fIHTTP::Request\fR objects. |
175 | The state of a \fIHTTP::Cookies\fR object can be saved in and restored from |
176 | files. |
177 | .SH "METHODS" |
178 | .IX Header "METHODS" |
179 | The following methods are provided: |
180 | .IP "$cookie_jar = HTTP::Cookies\->new" 4 |
181 | .IX Item "$cookie_jar = HTTP::Cookies->new" |
182 | The constructor takes hash style parameters. The following |
183 | parameters are recognized: |
184 | .Sp |
185 | .Vb 4 |
186 | \& file: name of the file to restore cookies from and save cookies to |
187 | \& autosave: save during destruction (bool) |
188 | \& ignore_discard: save even cookies that are requested to be discarded (bool) |
189 | \& hide_cookie2: do not add Cookie2 header to requests |
190 | .Ve |
191 | .Sp |
192 | Future parameters might include (not yet implemented): |
193 | .Sp |
194 | .Vb 3 |
195 | \& max_cookies 300 |
196 | \& max_cookies_per_domain 20 |
197 | \& max_cookie_size 4096 |
198 | .Ve |
199 | .Sp |
200 | .Vb 1 |
201 | \& no_cookies list of domain names that we never return cookies to |
202 | .Ve |
203 | .ie n .IP "$cookie_jar\->add_cookie_header( $request )" 4 |
204 | .el .IP "$cookie_jar\->add_cookie_header( \f(CW$request\fR )" 4 |
205 | .IX Item "$cookie_jar->add_cookie_header( $request )" |
206 | The \fIadd_cookie_header()\fR method will set the appropriate Cookie:\-header |
207 | for the \fIHTTP::Request\fR object given as argument. The \f(CW$request\fR must |
208 | have a valid url attribute before this method is called. |
209 | .ie n .IP "$cookie_jar\->extract_cookies( $response )" 4 |
210 | .el .IP "$cookie_jar\->extract_cookies( \f(CW$response\fR )" 4 |
211 | .IX Item "$cookie_jar->extract_cookies( $response )" |
212 | The \fIextract_cookies()\fR method will look for Set\-Cookie: and |
213 | Set\-Cookie2: headers in the \fIHTTP::Response\fR object passed as |
214 | argument. Any of these headers that are found are used to update |
215 | the state of the \f(CW$cookie_jar\fR. |
216 | .ie n .IP "$cookie_jar\->set_cookie( $version\fR, \f(CW$key\fR, \f(CW$val\fR, \f(CW$path\fR, \f(CW$domain\fR, \f(CW$port\fR, \f(CW$path_spec\fR, \f(CW$secure\fR, \f(CW$maxage\fR, \f(CW$discard, \e%rest )" 4 |
217 | .el .IP "$cookie_jar\->set_cookie( \f(CW$version\fR, \f(CW$key\fR, \f(CW$val\fR, \f(CW$path\fR, \f(CW$domain\fR, \f(CW$port\fR, \f(CW$path_spec\fR, \f(CW$secure\fR, \f(CW$maxage\fR, \f(CW$discard\fR, \e%rest )" 4 |
218 | .IX Item "$cookie_jar->set_cookie( $version, $key, $val, $path, $domain, $port, $path_spec, $secure, $maxage, $discard, %rest )" |
219 | The \fIset_cookie()\fR method updates the state of the \f(CW$cookie_jar\fR. The |
220 | \&\f(CW$key\fR, \f(CW$val\fR, \f(CW$domain\fR, \f(CW$port\fR and \f(CW$path\fR arguments are strings. The |
221 | \&\f(CW$path_spec\fR, \f(CW$secure\fR, \f(CW$discard\fR arguments are boolean values. The \f(CW$maxage\fR |
222 | value is a number indicating number of seconds that this cookie will |
223 | live. A value <= 0 will delete this cookie. \f(CW%rest\fR defines |
224 | various other attributes like \*(L"Comment\*(R" and \*(L"CommentURL\*(R". |
225 | .IP "$cookie_jar\->save" 4 |
226 | .IX Item "$cookie_jar->save" |
227 | .PD 0 |
228 | .ie n .IP "$cookie_jar\->save( $file )" 4 |
229 | .el .IP "$cookie_jar\->save( \f(CW$file\fR )" 4 |
230 | .IX Item "$cookie_jar->save( $file )" |
231 | .PD |
232 | This method file saves the state of the \f(CW$cookie_jar\fR to a file. |
233 | The state can then be restored later using the \fIload()\fR method. If a |
234 | filename is not specified we will use the name specified during |
235 | construction. If the attribute \fIignore_discard\fR is set, then we |
236 | will even save cookies that are marked to be discarded. |
237 | .Sp |
238 | The default is to save a sequence of \*(L"Set\-Cookie3\*(R" lines. |
239 | \&\*(L"Set\-Cookie3\*(R" is a proprietary \s-1LWP\s0 format, not known to be compatible |
240 | with any browser. The \fIHTTP::Cookies::Netscape\fR sub-class can |
241 | be used to save in a format compatible with Netscape. |
242 | .IP "$cookie_jar\->load" 4 |
243 | .IX Item "$cookie_jar->load" |
244 | .PD 0 |
245 | .ie n .IP "$cookie_jar\->load( $file )" 4 |
246 | .el .IP "$cookie_jar\->load( \f(CW$file\fR )" 4 |
247 | .IX Item "$cookie_jar->load( $file )" |
248 | .PD |
249 | This method reads the cookies from the file and adds them to the |
250 | \&\f(CW$cookie_jar\fR. The file must be in the format written by the \fIsave()\fR |
251 | method. |
252 | .IP "$cookie_jar\->revert" 4 |
253 | .IX Item "$cookie_jar->revert" |
254 | This method empties the \f(CW$cookie_jar\fR and re-loads the \f(CW$cookie_jar\fR |
255 | from the last save file. |
256 | .IP "$cookie_jar\->clear" 4 |
257 | .IX Item "$cookie_jar->clear" |
258 | .PD 0 |
259 | .ie n .IP "$cookie_jar\->clear( $domain )" 4 |
260 | .el .IP "$cookie_jar\->clear( \f(CW$domain\fR )" 4 |
261 | .IX Item "$cookie_jar->clear( $domain )" |
262 | .ie n .IP "$cookie_jar\->clear( $domain\fR, \f(CW$path )" 4 |
263 | .el .IP "$cookie_jar\->clear( \f(CW$domain\fR, \f(CW$path\fR )" 4 |
264 | .IX Item "$cookie_jar->clear( $domain, $path )" |
265 | .ie n .IP "$cookie_jar\->clear( $domain\fR, \f(CW$path\fR, \f(CW$key )" 4 |
266 | .el .IP "$cookie_jar\->clear( \f(CW$domain\fR, \f(CW$path\fR, \f(CW$key\fR )" 4 |
267 | .IX Item "$cookie_jar->clear( $domain, $path, $key )" |
268 | .PD |
269 | Invoking this method without arguments will empty the whole |
270 | \&\f(CW$cookie_jar\fR. If given a single argument only cookies belonging to |
271 | that domain will be removed. If given two arguments, cookies |
272 | belonging to the specified path within that domain are removed. If |
273 | given three arguments, then the cookie with the specified key, path |
274 | and domain is removed. |
275 | .IP "$cookie_jar\->clear_temporary_cookies" 4 |
276 | .IX Item "$cookie_jar->clear_temporary_cookies" |
277 | Discard all temporary cookies. Scans for all cookies in the jar |
278 | with either no expire field or a true \f(CW\*(C`discard\*(C'\fR flag. To be |
279 | called when the user agent shuts down according to \s-1RFC\s0 2965. |
280 | .IP "$cookie_jar\->scan( \e&callback )" 4 |
281 | .IX Item "$cookie_jar->scan( &callback )" |
282 | The argument is a subroutine that will be invoked for each cookie |
283 | stored in the \f(CW$cookie_jar\fR. The subroutine will be invoked with |
284 | the following arguments: |
285 | .Sp |
286 | .Vb 11 |
287 | \& 0 version |
288 | \& 1 key |
289 | \& 2 val |
290 | \& 3 path |
291 | \& 4 domain |
292 | \& 5 port |
293 | \& 6 path_spec |
294 | \& 7 secure |
295 | \& 8 expires |
296 | \& 9 discard |
297 | \& 10 hash |
298 | .Ve |
299 | .IP "$cookie_jar\->as_string" 4 |
300 | .IX Item "$cookie_jar->as_string" |
301 | .PD 0 |
302 | .ie n .IP "$cookie_jar\->as_string( $skip_discardables )" 4 |
303 | .el .IP "$cookie_jar\->as_string( \f(CW$skip_discardables\fR )" 4 |
304 | .IX Item "$cookie_jar->as_string( $skip_discardables )" |
305 | .PD |
306 | The \fIas_string()\fR method will return the state of the \f(CW$cookie_jar\fR |
307 | represented as a sequence of \*(L"Set\-Cookie3\*(R" header lines separated by |
308 | \&\*(L"\en\*(R". If \f(CW$skip_discardables\fR is \s-1TRUE\s0, it will not return lines for |
309 | cookies with the \fIDiscard\fR attribute. |
310 | .SH "SEE ALSO" |
311 | .IX Header "SEE ALSO" |
312 | HTTP::Cookies::Netscape, HTTP::Cookies::Microsoft |
313 | .SH "COPYRIGHT" |
314 | .IX Header "COPYRIGHT" |
315 | Copyright 1997\-2002 Gisle Aas |
316 | .PP |
317 | This library is free software; you can redistribute it and/or |
318 | modify it under the same terms as Perl itself. |